views:

50

answers:

1

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?

+2  A: 

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));
LukeH
+1 Totally right!
FFire