wpf DependencyProperty Not accepting default value for short
Posted
by biju
on Stack Overflow
See other posts from Stack Overflow
or by biju
Published on 2010-04-16T12:39:57Z
Indexed on
2010/04/16
12:43 UTC
Read the original article
Hit count: 411
Hi, I was trying to use tis depencency property in my code but it gives me error says that Default value type does not match type of property 'MyProperty'.But short should accept 0 as default value.Ans also if i try to give null as default value it works..even if its a non nullabel type.How come this happens..
public short MyProperty
{
get { return (short)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(short), typeof(Window2), new UIPropertyMetadata(0));
© Stack Overflow or respective owner