Silverligh 4, VS 2010.
Making a Custom Control. (Non just UserControl, but public class HandPart : Control, and a template in \themes)
Then I creating a new DependencyProperty with a helper snippet:
#region SomeDouble (DependencyProperty)
/// <summary>
/// A description of the property.
/// </summary>
public Double SomeDouble
{
get { return (Double)GetValue(SomeDoubleProperty); }
set { SetValue(SomeDoubleProperty, value); }
}
public static readonly DependencyProperty SomeDoubleProperty =
DependencyProperty.Register("SomeDouble", typeof(Double), typeof(HandPart),
new PropertyMetadata(0));
#endregion
As a result solution is compiling with out any errors and messages but it not starting up. When I creating DependencyProperty with, fore example, Int type insted Double or Single, it's working OK.
What is the problem, (feature?) with float? Why I can't create DP with a floats types?
The 0
argument that you're passing to the PropertyMetadata
constructor will be interpreted as an int
rather than a double
. Try passing 0.0
instead:
public static readonly DependencyProperty SomeDoubleProperty =
DependencyProperty.Register("SomeDouble", typeof(Double),
typeof(HandPart), new PropertyMetadata(0.0));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With