2010-11-15 31 views

回答

1

您可以使用以下方法檢查視圖是否已添加到區域。

var regionManager = Get reference to the region manager 
bool viewHasBeenAdded = regionManager.Regions["Your region"].GetView("View Name") != null; 

這是你想要或者你真的想檢查類型而不是查看名稱?

3

(使用LINQ)下面的代碼應該是有用的:

regionManager.Regions["RegionName"].Views.Any(v => v.GetType() == typeof(ViewType)); 

希望這有助於

0
object obj = System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(cntrlName); 

var checkIfAlreadyExists = 
RegionManager.Regions["ApplicationCoreRegion"].Views.Contains(obj); 

if (checkIfAlreadyExists) { 
    MessageBox.Show("Can not add this, because it is already shown"); 
} else { 
    RegionManager.RegisterViewWithRegion("ApplicationCoreRegion",() => obj); 
    RegionManager.Regions["ApplicationCoreRegion"].Activate(obj); 
} 
相關問題