Region lifetime #2458
-
I heard at some Brian's videos that region is created once requested and then Prism just changes regions when user navigates, but does not recreate them. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I believe you're getting a little confused here... If a view (for simplicity we'll say a Page, but could be literally any View) contains a child which added the That said no child content is necessarily added to the Region until you call RequestNavigate. In Prism 8.1 which was released yesterday there are some new APIs that do make it possible to register Views for Regions so that when a Region is created then one or more Views can be added to the Region immediately. Prism.Forms.Regions does contain a bunch of tests which you can use for guidance as well as by looking at the e2e app's HelloRegions module. |
Beta Was this translation helpful? Give feedback.
-
I have found the answer on my question. I should use public bool IsNavigationTarget(INavigationContext navigationContext)
{
return true;
} Then Prism stops to create new instance of the region view model each time I navigate to it. |
Beta Was this translation helpful? Give feedback.
I have found the answer on my question. I should use
IRegionAware
interface for my region view model and returntrue
from theIsNavigationTarget
method.Then Prism stops to create new instance of the region view model each time I navigate to it.