I have been reading on Dependency properties for a few days and understand how they retrieve the value rather than to set/get them as in CLR properties. Feel free to correct
You can use attached properties for it.
Define your property MyInt:
namespace WpfApplication5
{
public class MyProperties
{
public static readonly System.Windows.DependencyProperty MyIntProperty;
static MyProperties()
{
MyIntProperty = System.Windows.DependencyProperty.RegisterAttached(
"MyInt", typeof(int), typeof(MyProperties));
}
public static void SetMyInt(System.Windows.UIElement element, int value)
{
element.SetValue(MyIntProperty, value);
}
public static int GetMyInt(System.Windows.UIElement element)
{
return (int)element.GetValue(MyIntProperty);
}
}
}
Bind label content: