I'm having issues binding to a custom class. The dependencyproperty does not seem to get the correct value from my viewmodel. Here is my custom class:
public class DataResource : DependencyObject
{
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content",
typeof(object),
typeof(DataResource));
public object Content
{
get { return (object)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
}
And in my UserControl resources, I have:
<UserControl.Resources>
<local:DataResource x:Key="dataResource" Content="{Binding Test}"></data:DataResource>
</UserControl.Resources>
"Test" in my ViewModel is a property that I can bind a Label to with no issues. Am I doing something wrong here in this implementation?
Update: This works if I inherit from Freezable instead of DependencyObject. I'm not quite sure why, hopefully somone can explain this.