WPF TreeView with icons and text
c#, wpf
Solution
Try something like this:
<TreeView ItemsSource="{Binding SomeData}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Icon}" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
See this for how to bind the image in more detail: Binding image source through property in wpf
Problem
Working on learning WPF by converting my win forms apps. Currently having a hard time figuring out how to add TreeViewItems to a TreeView that contains am image before text all on the same line. My images are png files that are listed as a resource. I want to be able to specify the image and text of each item. Everything I have been seeing are setting default images. Would really appreciate the help. Thanks