gpt4 book ai didi

c# - PRISM:区域未向 RegionManager 注册

转载 作者:行者123 更新时间:2023-11-30 12:24:30 24 4
gpt4 key购买 nike

我有一个自定义控件,它派生自用户控件。

public class CustomControl : ContentControl 
{
public static readonly DependencyProperty VisualCompareControlProperty = DependencyProperty.Register("VisualCompareControl", typeof (FrameworkElement), typeof (CustomControl), new PropertyMetadata(default(FrameworkElement)));
public FrameworkElement VisualCompareControl
{
get { return (FrameworkElement) GetValue(VisualCompareControlProperty); }
set { SetValue(VisualCompareControlProperty, value); }
}
}

这是我的“ View ”:

<myNameSpace:CustomControl>
<VisualCompareControl prism:RegionManager.RegionName="MyRegion" />
</myNameSpace:CustomControl>

导航 View 并将 View 注入(inject)该区域是通过标准方式完成的:

RegionManager.RequestNavigate("MyRegion", navigation, navigationParameter);

当我调试区域“MyRegion”时,未在 RegionManager 中注册。怎么会?有什么想法吗?

最佳答案

您必须通过声明了区域适配器的控件来声明区域。我假设您的 VisualCompareControl 类型的 FrameworkElement 控件没有。

您可以 create a custom region adapter为此,或使用带有开箱即用的 Prism 适配器的三个控件之一:ContentControlItemsControlSelector 派生控件。

因为 CustomControl 派生 ContentControl 你可以尝试:

<myNameSpace:CustomControl prism:RegionManager.RegionName="MyRegion" />

或者您可以直接访问 ContentControl:

<ContentControl prism:RegionManager.RegionName="MyRegion" />

关于c# - PRISM:区域未向 RegionManager 注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33994156/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com