I am having a custom canvas derived from Canvas. It contains few ApplicationCommands like New/Open/Save etc. added like this –
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.New, New_Executed,
New_Enabled));
New_Enabled always returns true.
This control is used in a wpf project having a menu bar; New/Open/Save menu button’s are present in this menu bar with their Command set to respective ApplicationCommand like this –
<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>
Command works correctly when focus is present on Canvas but as soon as focus shifts to other control, New button gets disabled. I have tried setting CommandTarget to main window but that too doesn’t work.
Why this is happening and how can to make sure that New menu button will always be enabled?
@repka – Thanks for your response; I had already tried using canvas name as
CommandTargetbut it doesn’t work; Buttons gets enabled only when focus is on canvas as soon as i Click on some other control in window they gets disabled. I also tried usingIsFocusScopebut same result. Thanks for the command name strings tip.I had to settle with this workaround, although I am not too happy with this –