Search code examples
wpftreeviewdouble-clicktreeviewitem

WPF Double Click TreeviewItem Child Node


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.


Solution

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