开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜