我在WindowsFormsHost中有一個Forms.DataVisualization.Charting.Chart。我無法讓圖表接收鼠標滾輪事件。點擊工作,如果我嘗試使用Forms.TextBox鼠標滾輪也在工作。如果我在「本地」表單應用中使用圖表,鼠標滾輪也可以工作。WindowsFormsHost中的Windows窗體圖表沒有收到鼠標滾輪?
那麼,是什麼使得問題是formsHost中形式圖的組合。
這裏是一個檸簡單的應用程序複製問題:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Name="TextBlock1" Grid.Column="1" />
<WindowsFormsHost Name="WindowsFormsHost1" Grid.Column="0"/>
</Grid>
和後面的代碼:
public MainWindow()
{
InitializeComponent();
var chart = new Chart() { BackColor = System.Drawing.Color.Aquamarine};
WindowsFormsHost1.Child = chart;
chart.MouseDown += (a, b) => TextBlock1.Text += "FORMS click\r\n";
TextBlock1.MouseDown += (a, b) => TextBlock1.Text += "WPF click\r\n";
chart.MouseWheel += (a, b) => TextBlock1.Text += "FORMS wheel\r\n";
TextBlock1.MouseWheel += (a, b) => TextBlock1.Text += "WPF wheel\r\n";
}
可以接收所有點擊和從WPF鼠標滾輪,但是沒有從輪形式。我也嘗試了FormsHost的車輪聽衆,但沒有成功。
任何想法? Jon Skeet?
謝謝你的解釋,但是這並不能幫助我很多solfing問題。我想我需要手動排除事件,但我不知道如何。我也嘗試捕獲在WPF中的鼠標滾輪發送我自己的命令的形式,但我無法捕捉WPF中的輪...你能提供代碼片段或想法如何克服這個問題嗎? –