我有一個按鈕,需要執行兩個單獨的命令(一個開始一些事情,一個停止它)。在做了一些研究之後,System.Windows.Interactivity.dll似乎提供了一種簡單的方法來實現這一點。不過,這並不用鼠標左鍵工作(它的工作,如果我使用一個事件像MouseDoubleClick或的MouseRightButtonDown,但不的MouseDown,的MouseUp,或的MouseRightButtonDown)......它似乎如果按鈕消耗事件本身並且interaction.trigger永遠不會看到它。我在下面提供了我的XAML的片段,我能做些什麼來解決此問題?如何在XAML中的MouseUp和MouseDown事件上使用Interaction Trigger on按鈕?
<Button Content="DoStuff">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding StartCommand}" />
</i:EventTrigger>
<i:EventTrigger EventName="MouseUp">
<i:InvokeCommandAction Command="{Binding StopCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
你甚至在拍攝按鈕類一看就檢查什麼事件都可以用? http://msdn.microsoft.com/en-us/library/system.windows.controls.button.aspx –
是的,那是我做的第一件事。我嘗試了PreviewDown/Up,MouseDown/Up,PreviewMouseLeftButtonDown/Up,MouseLeftButtonDown/Up和PreviewMouseDown/Up,但它們都不起作用。 – AXG1010