I have an ItemTemplateSelector which contains Multiple DataTemplates which have Different DataTypes. I thus have multiple ItemSources based on Module Selected. How to bind my ListView with multiple ItemSources based on the module selected?
Explanation:
1)ViewModel_A is my ItemSource and DataTemplateA is my DataTemplate when my Module A is Selected
2)ViewModel_B is my ItemSource DataTemplateB is my DataTemplate when my Module B is Selected
I tried Implementing a BaseViewModel and tried binding the BaseViewModel Type in my ItemSource But this doesn't allow the access of derived class properties.
How to Dynamically Select My ItemSource?
Step 1
First Create a
UserControlwhich contains yourListViewin your Xaml and twoDependancyPropertyforItemSourceandDataTemplateDataList.Xaml
DataList.xaml.cs
Step 2
Now you can you this usercontrol with any multiple DataTemplate's and multiple itemsource as below
MainPage.xaml
MainPage.xaml.cs