我有一个从Canvas
. 它包含很少的ApplicationCommands
like New
// etc. 添加这样Open
-Save
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.New, New_Executed,
New_Enabled));
New_Enabled
总是返回真。
此控件用于具有菜单栏的 wpf 项目中;新/打开/保存菜单按钮出现在此菜单栏中,它们的Command
设置分别ApplicationCommand
如下 -
<syncfusion:SimpleMenuButton
x:Name="NewMenu"
Icon="Images\New_Large.png"
Label="New"
IsEnabled="True"
Command="{x:Static ApplicationCommands.New}"
syncfusion:Ribbon.KeyTip="N">
</syncfusion:SimpleMenuButton>
当焦点存在时,命令可以正常工作,Canvas
但一旦焦点转移到其他控件,新按钮就会被禁用。我试过设置CommandTarget
到主窗口,但这也不起作用。
为什么会发生这种情况以及如何确保始终启用新菜单按钮?