I have a usercontrol that contains a TreeView control. I am using the MVVM pattern. I want to reuse this user control in different windows, each time binding the usercontrol to another datacontext.
<UserControl Name="UserControl1".......>
..............
<TreeView ItemSource={Binding ...}...>
<HierarchicalDataTemplate...........\>
</TreeView>
..............
</UserControl>
In window 1, I want to bind List<ObjectA>to a TreeView.
In window 2, I want to bind List<ObjectB>to a TreeView.
Is it possible to write a generic ViewModel for this user control so that I can bind different data types to a TreeView ?? If my question is not understood, please let me know.
source
share