WPF Prism, how to have recurring views within a region

I am currently working with a Tab control and created a region so that it becomes my host.

what I'm trying to do is add the same look to the region twice. You may ask why? and because the application works in a simple chat application - there will be many instances of the presentation, but each will have different information.

my code is still ;;

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 as a whole ;;

  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 ... Is it possible to have duplicate views within a region? When I try to do this, I am currently getting an exception from the fact that it is already registered. I really need to get around this or create a region that will allow this.

Thanks for any help !!

greetings. Ste.

+6
source share
2 answers

Try it.

 IRegion TabRegion = manager.Regions["TabRegion"]; tabRegion.Add(convDetailsView1); tabRegion.Add(convDetailsView2); 
+2
source

try this solution:

 IRegion TabRegion = manager.Regions["TabRegion"]; tabRegion.Add(convDetailsView1).AdToRegion("make your region here",convDetailsView2); 
0
source

Source: https://habr.com/ru/post/913401/


All Articles