0

我在我的班级和 XAML 中定义了 RoutedCommand

Public Shared CustomCommandShowAll As New RoutedCommand

Public Shared CustomCommandFirstPage As New RoutedCommand

Public Shared CustomCommandSecondPage As New RoutedCommand



<Window.CommandBindings>
        <CommandBinding Command="local:DynamicTab.CustomCommandShowAll" Executed="ShowAll_Executed" />
        <CommandBinding Command="local:DynamicTab.CustomCommandFirstPage" Executed="FirstPage_Executed" />
        <CommandBinding Command="local:DynamicTab.CustomCommandSecondPage" Executed="Secondpage_Executed" />
    </Window.CommandBindings>

    <Window.InputBindings>
        <KeyBinding Command="local:DynamicTab.CustomCommandShowAll" Key="F1" Modifiers="Alt"/>
        <KeyBinding Command="local:DynamicTab.CustomCommandFirstPage" Key="F2" Modifiers="Alt"/>
        <KeyBinding Command="local:DynamicTab.CustomCommandSecondPage" Key="F3" Modifiers="Alt"/>
    </Window.InputBindings>

这些绑定由Menuitems连接

<Menu DockPanel.Dock="Top" >

                <MenuItem x:Name="filtermenu" Header="_FilterType" BorderBrush="White" >

                    <MenuItem Header="ShowAll" IsChecked="True" InputGestureText="Alt+F1"/>

                    <MenuItem Header="FirstPage" InputGestureText="Alt+F2"/>

                    <MenuItem Header="Secondpage" InputGestureText="Alt+F3"/>
                </MenuItem>
            </Menu>

现在,当我按下时ALT+F1ShowAll_Executed方法会接到一个电话,这里我有两个参数ByVal sender As System.Object, ByVal e As System.Windows.Input.ExecutedRoutedEventArgs

    Private Sub ShowAll_Executed(ByVal sender As System.Object, ByVal e As System.Windows.Input.ExecutedRoutedEventArgs)

End Sub

我不知道如何从这两个参数中获取ShowAll * MenuItem Header Name *,如果我得到该值,我只能对所有三个 MenuItem 使用一个RoutedCommand。提前致谢。

4

0 回答 0