У меня проблемы с установкой моего ContentProperty на "Текст". Ошибка, которую мне дают:
Недопустимый атрибут ContentPropertyAttribute для типа «MyType», свойство «Text» не найдено.
Код выглядит следующим образом:
[ContentProperty("Text")]
public partial class MyType: UserControl
{
public MyType()
{
InitializeComponent();
}
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text",
typeof (string),
typeof(MyType)));
public static string GetText(DependencyObject d)
{
return (string) d.GetValue(TextProperty);
}
public static void SetText(DependencyObject d, string value)
{
d.SetValue(TextProperty, value);
}
public string Text
{
get
{
return (string)GetValue(TextProperty);
}
set
{
SetValue(TextProperty, value);
}
}
}
Я действительно заставил его работать, если я назову свойством CLR что-то отличное от DependencyProperty - я неправильно использую DependencyProperties?