WPF Double Click TreeviewItem Child Node

tcables picture tcables · Nov 28, 2010 · Viewed 21.8k times · Source

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.

Answer

Aurelien Ribon picture Aurelien Ribon · Nov 28, 2010
<TreeView.ItemContainerStyle>
    <Style TargetType="{x:Type TreeViewItem}">
        <EventSetter Event="MouseDoubleClick" Handler="OnItemMouseDoubleClick" />
        ...