I am having trouble setting my ContentProperty to "Text". The error I am given is:
Invalid ContentPropertyAttribute on type 'MyType', property 'Text' not found.
The code behind looks like this:
[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);
}
}
}
I have actually got it to work if I name the CLR property something other than the DependencyProperty - am I using DependencyProperties incorrectly?