Prismatic switch between views in the same region

I have an area called "ActiveModule" and you want to reuse it with different views, for example, you click the search button and I show the type of search there, etc. etc.

The only way I can use an ATM is to deactivate all active views in this region, and then activate the view I like, it's a little dirty, is there a "viewManager" or something similar that I can use?

+3
source share
5 answers

If your region is ContentControl or obtained from ContentControl, then there can only be one active view at a time, and you only need to activate the search in the region.

+4
source

Do you consider using a type of contentControl that can display multiple views? For example, you can use TabControl as follows:

<TabControl Name="MainRegion" Regions:RegionManager.RegionName="MainRegion"/>

Now you can add several areas to the region. Use interfaces INavigationAwareand IActiveAwareby Prism, to be able to navigate by type (enable them to find the right kind, etc.).

+1
source

IRegionManager, , , .

    foreach (var view in _regionsManager.Regions["MyRegion"].Views.ToArray())
    {
        if (view is MyType ||
            view is MyOtherType)
            _regionsManager.Regions["MyRegion"].Remove(view);
    }

    _regionsManager.AddToRegion("MyRegion", typeof(MyView));

, .:)

0

, , , SCSF . ViewManager ShowViewService, . , !

0

, , ,

regionManager.RequestNavigate(RegionNames.MainContentRegion, new Uri("your target view" + parameters, UriKind.Relative));

.

, ,

region.Activate(view);
0

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


All Articles