Duplicating my StackOverflow question here (http://stackoverflow.com/questions/2835759/) , since no-one answers it there even after I added bounty to it:
I'm getting weird behavior with command propagation from
I have the following kind of layout:
ContextMenu is set for each
UserControl, which in its turn is inside
DockableContent of AvalonDock. If I get rid of either docking or
UserControl around my grid there are no problems.
ListBox instead of
DataGrid doesn't have this issue either.
Title="MainWindow" Height="350" Width="525">
Code-behind is trivial as well:
public partial class MainWindow
Tuple.Create(1, 2, 3),
Tuple.Create(4, 4, 3),
Tuple.Create(6, 7, 1),
private void ExecuteZoom(object sender, ExecutedRoutedEventArgs e)
private void CanZoom(object sender, CanExecuteRoutedEventArgs e)
e.CanExecute = true;
So here's the problem: right-clicking on the selected row (if it it was selected before the right click) my command comes out disabled. The command is "Zoom" in this case, but can be any other, including a custom one.
I don't know what's at fault here. SNOOP shows that in cases when this propagation fails, instead of
CanExecute is handled by "PART_ShowContextMenuButton" (Button), which is part of docking header.
I've had other issues with UI command propagation within
UserControls hosted inside AvalonDock, but this one is the easiest to reproduce.