我有一个自定义通用用户控件,我希望有一个名为AdditionalContent
的内容属性。删除所有非错误特定代码的减少实现是。
[ContentProperty("AdditionalContent")]
public class WgReactiveUserControl<TViewModel> : UserControl
where TViewModel : class
{
public UIElement AdditionalContent
{
get { return ( UIElement ) GetValue(AdditionalContentProperty); }
set { SetValue(AdditionalContentProperty, value); }
}
public static readonly DependencyProperty AdditionalContentProperty =
DependencyProperty
.Register("AdditionalContent",
typeof(UIElement),
typeof(WgReactiveUserControl<TViewModel>),
new PropertyMetadata(null));
}
我在设计器中遇到以下错误。
引用此代码。
纯文本代码是
<w:MeasuredViewportLayoutHelpPanelBase
x:Class="Weingartner.EyeshotExtensions.MeasuredViewportLayoutHelpPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:w="clr-namespace:Weingartner.EyeshotExtensions"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
d:DataContext="{d:DesignInstance w:MeasuredViewportLayoutHelpPanelModel, d:IsDesignTimeCreatable=false}">
<Border BorderThickness="1" Background="#C0333333" BorderBrush="#C0D4D4D4" Margin="20">
</Border>
</w:MeasuredViewportLayoutHelpPanelBase>
代码背后是
public class MeasuredViewportLayoutHelpPanelModel
{ }
public class MeasuredViewportLayoutHelpPanelBase
: WgReactiveUserControl<MeasuredViewportLayoutHelpPanelModel>
{ }
public partial class MeasuredViewportLayoutHelpPanel
: MeasuredViewportLayoutHelpPanelBase
{
}
我无法弄清楚依赖属性AdditionalContent
的声明可能会导致设计器发出此错误的错误。