我有一個從MvvmLight.ViewModelBase派生的基類,它具有處理對象選擇的額外職責。這個類定義在視圖結合的RelayCommand<MouseButtonEventArgs>
屬性:GalaSoft.MvvmLight.EventToCommand <T> args始終爲空
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<galaxcmd:EventToCommand Command="{Binding SelectCommand,Mode=OneWay}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
這種觀點是使用了含觀點,我現在需要處理mousedowns裏面太多次。我的問題出現是因爲我不希望容器處理mousedown,如果它是由包含的視圖處理的。我認爲PassEventArgsToCommand是我解決這個問題的解決方案,因爲我計劃一個子VM來設置MouseButtonEventArgs.Handled = true
。不幸的是,MouseButtonEventArgs參數始終爲空。以防萬一,我也嘗試過RoutedEventArgs,甚至是EventArgs,但它們也都是null。
我在做什麼錯誤的EventToCommand(或EventTrigger?)?
感謝您的建議。在引入PassEventArgsToCommand之前,您鏈接到的增強功能基於舊版本的EventToCommand,並試圖實現相同的目標。我希望能夠洞悉我當前的理解有什麼問題,但如果我解決不了,我會查看修改路線。 – AndyC