开发者

How to get the list of Regions in the RegionManager in PRISM?

开发者 https://www.devze.com 2023-03-12 15:26 出处:网络
I\'v got the following code : public class MyModule: IModule { private IRegionManager mRegionManager { get; set; }

I'v got the following code :

public class MyModule: IModule { private IRegionManager mRegionManager { get; set; }

    public CMBaseTable(IRegionManager regMan)
    {
        mRegionManager = regMan;
    }

    public void Initialize()
    {
        mRegionManager.RegisterViewWithRegion("MainRegion",typeof(MyView));
        var vs = mRegionManager.Regions["MainRegion"].Views;//<--- I get an exception here
    }
}

In the line

var vs = mRegionManager.Regions["MainRegion"].Views;

I'll get an exception that says: KeyNotFoundException : "The region manager does not contain the MainRegion region."

But I'm sure that MainRegin is defined and other modules have ad开发者_高级运维ded views in it.


You can always take a look into the source. RegionCollection implements IEnumarable so you can iterate over the collection or you can simply use the provided function public bool ContainsRegionWithName(string regionName).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号