2018-06-22から1日間の記事一覧
Vとバインドしたプロパティに対して VM側で値を変更する処理を記述する場合、アクセサでなくプライベート変数に変更をかけた方がいいのではないかという話。 以下、サンプルソースです。 今回の話題に必要なパートのみを抜粋した状態です。 <TextBox Text="{Binding Path=MyVmString01, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" /> <Button Content="AddText" Command="{Binding Path=AddTextCommand}" /> /// <summary> /// プ…</summary></button></textbox>
xamlでなく、ソースからバインド設定をするには、SetBinding メソッドを使用します。 (例) Button myButton01 = new Button(); // Content に「MyString01」というプロパティとのバインディング設定を追加 myButton01.SetBinding(Button.ContentProperty, …