I thought that question sounded familiar. :)
So, you should just be able to use the same code, but then use Visual Studio to Find and Replace TreeView
to ListView
. Of course there are a few parts like the Image.Source
and the IsMouseDirectlyOverItem
helper that you may need to alter more carefully. For the most part, the Find and Replace function should work. TreeView
and ListView
have absolutely loads of identical properties.
Let me know if you have any problems doing this.
You can change your HierarchicalDataTemplate
to a normal one like this:
<DataTemplate DataType="{x:Type viewmodels:ObjectBaseViewModel}">
<StackPanel Orientation="Horizontal" Margin="2,1,5,2">
<Grid Margin="0,0,3,0">
<Image Name="icon" Source="/ExplorerTreeView/Images/folder.png"/>
</Grid>
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
Let me know if I have misunderstood your problem.