我正在使用 Microsoft for WPF 的 Ribbons Control Libary 在我们的 WPF 应用程序中提供功能区。
我们在 XAML 部分中按以下方式使用拆分按钮:
<r:RibbonSplitButton Label="SplitButtonLabel" LargeImageSource="..." Command="{Binding SplitButtonCommand}">
<r:RibbonSplitMenuItem Header="Item 1" ImageSource="..." Command="{Binding Command1}"/>
<r:RibbonSplitMenuItem Header="Item 2" ImageSource="..." Command="{Binding Command2}"/>
<r:RibbonSplitMenuItem Header="Item 3" ImageSource="..." Command="{Binding Command3}"/>
</r:RibbonSplitButton>
如果我单击拆分按钮的上部,命令 SplitButtonCommand 将像平常一样执行一次。
如果我单击 SplitButton 的底部,然后单击任何菜单项(例如项 1),则该项的命令将执行两次。
有人知道导致问题的原因吗?
最佳答案
看来这可能是有意设计的,看看这篇文章。提到了一个解决方法:
Although this is the nature of RibbonControl you can try to workaround this by parsing the ExecutedRoutedEventArgs and check if the OriginalSource is the same as Source, if yes then get this command executed.
关于c# - RibbonSplitButton 命令执行两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21015467/