1
votes

I tried using a single view for multiple Regions located in different views.

View1 -> MyRegion1 uses SharedView
View2 -> MyRegion2 uses SharedView

The initial view is View1 and it successfully shows the SharedView. When I navigate to View2, it also shows the SharedView. Now when I navigate back to View1, the SharedView is gone. Are there other steps I need to do to render a shared view in different views during navigation changes? Thanks a lot.

1
I do this all the time, having same view in multiple regions. The way i programmed is setting the content property of the control and take the view from ServiceLocator. Control1.Content = ServiceLocator.Current.GetInstance<View1>(); and for control 2 Control2.Content = ServiceLocator.Current.GetInstance<View1>(); - nipiv
It seems Prism wants to have a different instance of the view for every regions. The same instance of a visual component cannot be added twice in the visual tree - randacun
@nipiv: NEVER, NEVER use ServiceLocator. When your application will become larger - you will loose control over it. Use Dependency Injection patter instead. It's some harder to learn, but works perfectly with huge applications - chopikadze
I know what you are talking, Mostly I use Dependency Injection. I recently doing my research, how is performance difference between using DI or service locator ? - nipiv

1 Answers

1
votes

Not Prism but WPF wants to have a different instance of the view. So, short answer to your question is - NO, it's not possible. Please, create in any way different instances of your SharedView