C# DependencyProperty

Use .Net runtime to store class properties

  • Register
    • DependencyProperty.Register(“X”, typeof(System.Int32), typeof(MyClass));
  • Use
    • (Int32)base.GetValue(MyClass.XProperty);
    • base.SetValue(MyClass.XProperty, value);

Example:


class MyClass
{
public static DependencyProperty XProperty =
DependencyProperty.Register("X", typeof(System.Int32),
typeof(MyClass));
...
public Int32 X
{
get { return ((Int32)(base.GetValue(MyClass.XProperty))); }
set { base.SetValue(MyClass.XProperty, value); }
}
}

This entry was posted in c#. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.