double型のプロパティに対するDependencyPropertyのテスト実行したところ実行時エラーが出たときに、ちょっとはまってしまいました。
定義したDependencyPropertyです。
// 実行時エラーになる例 public static readonly DependencyProperty DurationProperty = DependencyProperty.Register( "Duration", typeof(double), typeof(ExPanel), new PropertyMetadata(1)); // 「1」だとintと解釈されるのでdouble型のプロパティに設定できない
問題はPropertyMetadataでデフォルト値を指定している個所でした。単純に整数を書くとintと見なさるのですね。
double num = 1;
と書いてもOKなので、油断してしまいました。
正しいDependencyPropertyはこうですね。
// 正常動作するDependencyPropertyの定義例 public static readonly DependencyProperty DurationProperty = DependencyProperty.Register( "Duration", typeof(double), typeof(ExPanel), new PropertyMetadata(1D)); // 数字の末尾に「D」をつけてdouble型と明示する。