I'm currently working with the Tab control and have created a region so it will become my host.
what I'm trying to do is add the same view to a region twice.. you may ask why? and its because the application is going a simple chat app - there will many instances of the view but each will have different information.
my code so far;;
IConversationDetailsPresentationModel convDetailsView1 =
this.Container.Resolve<IConversationDetailsPresentationModel>();
IRegionManager manager = this.Container.Resolve<IRegionManager>();
manager.RegisterViewWithRegion("TabRegion", () => convDetailsView1);
IConversationDetailsPresentationModel convDetailsView2 =
this.Container.Resolve<IConversationDetailsPresentationModel>();
manager.RegisterViewWithRegion("TabRegion", () => convDetailsView2);
And my views are registered with unity like so;;
this.Container.RegisterType<IConversationDetailsPresentationModel, ConversationDetailsPresentationModel>(
new TransientLifetimeManager());
this.Container.RegisterType<IConversationDetailsView, ConversationDetailsView>(
new TransientLifetimeManager());
also, my XAML
<TabControl TabStripPlacement="Left"
Width="Auto"
Height="Auto"
cal:RegionManager.RegionName="TabRegion"
Name="TabRegion"
SelectedItem="{Binding SelectedTab}">
<TabControl.ContentTemplate>
<DataTemplate>
<ContentControl cal:RegionManager.RegionName="TabContentRegion">
</ContentControl>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
Edit : my actual question is this.. Is it possible to have duplicate views inside a region? When I try it currently I get an exception about it already being registered.. what I really need is to bypass this or possible create a region that will allow it.
thanks for any help!!
cheers. ste.
Try this.
IRegion TabRegion = manager.Regions["TabRegion"];
tabRegion.Add(convDetailsView1);
tabRegion.Add(convDetailsView2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With