Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PRISM:区域未注册到RegionManager_C#_Wpf_Prism - Fatal编程技术网

C# PRISM:区域未注册到RegionManager

C# PRISM:区域未注册到RegionManager,c#,wpf,prism,C#,Wpf,Prism,我有一个自定义控件,它派生自用户控件 public class CustomControl : ContentControl { public static readonly DependencyProperty VisualCompareControlProperty = DependencyProperty.Register("VisualCompareControl", typeof (FrameworkElement), typeof (CustomControl), new

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

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); }
    }
}
这是我的“观点”:

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

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

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

您可以使用它,也可以使用三个带有现成棱镜适配器的控件之一:
ContentControl
ItemsControl
Selector
派生控件

由于
CustomControl
派生
ContentControl
您可以尝试:

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