c# - RibbonSplitButton 命令执行两次

标签 c# .net wpf ribboncontrolslibrary

我正在使用 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.

RibbonMenuItem triggers command twice

关于c# - RibbonSplitButton 命令执行两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21015467/

相关文章:

.net - Visual Studio 2010 正在吞噬我的 DLL! - 构建后缺少引用的第三方 dll

c# - 哪种生成 GUID 的方法最能确保 GUID 真正唯一?

javascript - 如何从 JavaScript 调用 C# 函数?

c# - 事件参数; "sender as Object"或 "sender as T"?

c# - WinProcEvent 一个或多个 SetWinEventHook 回调?

wpf - ObservableCollection Remove() 未触发可见性绑定(bind)

wpf - 绑定(bind)到 ActualHeight 不起作用

c# - 找不到方法 : 'Void System.Diagnostics.Tracing.FrameworkEventSource.BeginGetResponse(System.Object, System.String)'

c# - 每 30 秒重复一次 ping

c# - TextBox 不遵守 Get 返回的值