本文介绍了WPF 双击 TreeviewItem 子节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在树视图中有一个树视图项,它将绑定一个列表:

I have a treeview Item as such in a treeview that will have a list bound to it:

        <TreeViewItem Name="tviOffline" Foreground="Red" FontWeight="Bold"
                      Header="Offline">
            <TreeViewItem.ItemTemplate>
                <DataTemplate DataType="{x:Type local:Buddy}">
                    <StackPanel>
                        <TextBlock Text="{Binding Nick}" FontSize="10" Foreground="#8CFFD528" />
                    </StackPanel>
                </DataTemplate>
            </TreeViewItem.ItemTemplate>
        </TreeViewItem>

我不知道如何让它的每个孩子都有一个双击事件.

I cannot figure out how to get each of its childs to have a double click event.

感谢任何帮助.非常感谢.

any help is appreciated. thanks much.

推荐答案

<TreeView.ItemContainerStyle>
    <Style TargetType="{x:Type TreeViewItem}">
        <EventSetter Event="MouseDoubleClick" Handler="OnItemMouseDoubleClick" />
        ...

这篇关于WPF 双击 TreeviewItem 子节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 01:38