我有一個地區,想檢查是否添加了特定的視圖類型。我該怎麼做?如何檢查PRISM中已添加到某個區域的視圖?
1
A
回答
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);
}
相關問題
- 1. PRISM:如何將視圖模型添加到區域並自動創建視圖?
- 2. 如何將視圖添加到PRISM TabControl區域而不進行選擇?
- 3. 將幾個視圖添加到Marionette中的某個區域的優雅方式
- 4. 如何檢查頁腳是否已添加到列表視圖?
- 5. 如何檢查控件是否已被添加到視圖?
- 6. prism wpf:如何在一個區域顯示視圖/模塊
- 7. MVVM-PRISM,如何顯示區域中的多個視圖實例/ ItemsControl
- 8. 如何從WPF Prism中的另一個視圖獲取視圖/區域的底層視圖模型
- 9. WPF Prism如何在區域內重複視圖
- 10. prism:如何將shell.xaml中的某些內容綁定到區域內容變量?
- 11. 從視圖中添加到區域的形狀的優先級
- 12. 構建視圖,在區域中添加新的子視圖
- 13. Prism中是否存在嵌套區域和視圖的限制?
- 14. WPF - Prism - 激活和停用ContentControl區域中的視圖
- 15. 如何將不在某個區域的控制器移動到某個區域?
- 16. 如何在ASP中添加空白區域。 NET MVC視圖
- 17. 如何檢查座標是否位於某個區域?
- 18. PRISM:區域內的嵌套區域
- 19. PRISM滾動區域
- 20. 如何添加動作到Ember.js中的地圖區域?
- 21. 如何添加點上的可視化:區域圖
- 22. 在現有導航窗口中添加PRISM區域管理器
- 23. 將圖像縮放到某個區域
- 24. 如何將特定區域的區域添加到Rails?
- 25. 添加視圖到ItemsControl的區域的頂部
- 26. 將子視圖添加到視圖的邏輯檢查 - iOS
- 27. PRISM - 重新使用子區域的視圖 - 可以完成嗎?
- 28. 如何檢測一個人是否已經進入谷歌地圖中的某個區域
- 29. 如何檢查某區域內的座標Python
- 30. 爲R中的某個區域添加陰影