0

我正在尝试将 Command 绑定到TreeViewNode. 为此,我拥有TextBlock和行动,我在其中拥有HyperlinkHyperlink与命令绑定:

<HierarchicalDataTemplate DataType="{x:Type vm:TreeNodeViewModel}" ItemsSource="{Binding Path=Children, Mode=OneWay}">
   <StackPanel Orientation="Horizontal" Margin="2 0 4 0">
         <Image Width="18" Height="18" Margin="0 0 4 0" Source="{Binding NodeImage}"/>

            <TextBlock>

                 <Hyperlink Command="{Binding Path=NodeActionCommand}" TextDecorations="None" Foreground="Black" Focusable="False">
                 <Run Text="{Binding Path=Name, Mode=OneWay}"/>

                 <!--Following Input binding is not working-->
                 <Hyperlink.InputBindings>
                       <KeyBinding Key="Enter" Command="{Binding Path=NodeActionCommand}"/>
                 </Hyperlink.InputBindings>
                 </Hyperlink>

            </TextBlock>
   </StackPanel>
</HierarchicalDataTemplate>

如果我鼠标单击节点,则此 XAML 工作,但在树命令节点上的键盘按键Enter未触发。请帮忙。

4

0 回答 0