I have a c# Windows Forms project with a WPF RichTextBox (in ElementHost) on the form and want to drag&drop a picture from the explorer (Windows 7 x64) into it, but the cursor shows only the not-allowed-symbol. This is my code:
private void Form1_Load(object sender, EventArgs e)
{
this.AllowDrop = true;
elementHost1.AllowDrop = true;
}
public UserControl1()
{
InitializeComponent();
Background = System.Windows.Media.Brushes.Transparent;
this.AllowDrop = true;
richTextBox1.AllowDrop = true;
}
The events are subscribed using the designer. None of them are fired:
private void richTextBox1_DragEnter(object sender, DragEventArgs e)
{
MessageBox.Show("Test");
}
private void richTextBox1_DragLeave(object sender, DragEventArgs e)
{
MessageBox.Show("Test");
}
private void richTextBox1_DragOver(object sender, DragEventArgs e)
{
MessageBox.Show("Test");
}
private void richTextBox1_Drop(object sender, DragEventArgs e)
{
MessageBox.Show("Test");
}
If i use a Windows Forms RichTextBox is works, but i need a WPF RichTextBox:
private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.AllowDrop = true;
richTextBox1.DragDrop += new DragEventHandler(richTextBox1_DragDrop);
}
private void richTextBox1_DragDrop(object sender, EventArgs e)
{
MessageBox.Show("Test");
}