I tried to use the tis depencency property in my code, but it gives me an error saying that the default value type does not match the "MyProperty" property type. But short should be set to 0 by default.
If I try to set it to null as the default value, it will work even if it is not null. How did it happen.
public short MyProperty { get { return (short)GetValue(MyPropertyProperty); } set { SetValue(MyPropertyProperty, value); } }
Using DependencyProperty as storage for MyProperty. This allows you to create animation, style, snapping, etc.
public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.Register( "MyProperty", typeof(short), typeof(Window2), new UIPropertyMetadata(0) );
source share