既存のコントロール (私の場合は ComboBox) を拡張して、ビュー モデルのプロパティにバインドできる新しいプロパティを含めるにはどうすればよいですか??
次のように、コントロールのクラスに依存関係プロパティがあります。
public class MyComboBox : ComboBox
{
public static readonly DependencyProperty MyTextProperty =
DependencyProperty.Register("MyText", typeof(string), typeof(MyComboBox));
public string MyText
{
get
{
return GetValue(MyComboBox.MyTextProperty).ToString();
}
set
{
SetValue(MyComboBox.MyTextProperty, value);
}
}
そして、次のように XAML から宣言的にバインドします。
<MyComboBox MyText="{Binding MyTextOnViewModel,
UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
バインディングが機能しません。なぜですか??
ありがとう。