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" />