我有几个在 ListBox 中实例化的用户控件。我的 Window 中有一个按钮 raises NavigationCommands.Refresh
,以及一个CanExecute
允许它执行的处理程序:
<Window.CommandBindings>
<CommandBinding Command="NavigationCommands.Refresh" CanExecute="CanAlwaysExecute" />
</Window.CommandBindings>
在每个动态创建的用户控件(在 ListBox 的 ItemTemplate 中创建)中,我都有一个NavigationCommands.Refresh
. 当我单击窗口中的按钮时,我在每个用户控件中设置的处理程序是否应该不触发?我需要命令来隧道到每个 UC,但它不是。
<UserControl.CommandBindings>
<CommandBinding Command="NavigationCommands.Refresh" Executed="UpdateStatus" CanExecute="CanAlwaysExecute" />
</UserControl.CommandBindings>
....
<Button Width="200" Text="Refresh All" Command="NavigationCommands.Refresh"/>