Here is the code I have that is functionnal :
<TreeView SelectedItemChanged="item_Clicked" Grid.Column="0" Grid.Row="0" VerticalAlignment="Stretch">
<TreeViewItem Header="Frame1" ItemsSource="{Binding Items}" IsExpanded="True">
<TreeViewItem.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</TreeViewItem.ItemTemplate>
</TreeViewItem>
</TreeView>
开发者_如何学运维
the thing is that I'd like to add an icon to the root-node "Frame1" I tried a lot of things with StackPanel & TreeViewItem.Items, but I don't manage to do it... I want the icon to be between the "+" (that expands the node) and the Header (Frame1).
Thanks in anticipation for any help and sry for my english :(
Here is an example:
<TreeViewItem ItemsSource="{Binding Items}" IsExpanded="True">
<TreeViewItem.Header>
<DockPanel>
<Image DockPanel.Dock="Left" Width="20" />
<TextBlock Text="Frame1" />
</DockPanel>
</TreeViewItem.Header>
<TreeViewItem.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</TreeViewItem.ItemTemplate>
</TreeViewItem>
I removed the SelectedItemChanged event for my brevity, so add it again.
Cheers
精彩评论