wpf mvvmで独立して動作する2つのテキストボックスがあります。しかし、今私はチェックボックスに基づいて他のテキストボックスに1つのテキストボックスの入力をバインドしたい。WPF - テキストボックスの内容をバインドするその他のテキストボックス
<Label Grid.Row="4" Grid.Column="0" Style="{StaticResource StlLblForm}" Margin="0,5">First Name:</Label>
<TextBox Grid.Row="4" MaxLength="10" Grid.Column="1" Style="{StaticResource StlTxtForm}" Text="{Binding FirstName}" Grid.ColumnSpan="2" Margin="0,1,0,11" />
<Label Grid.Row="5" Grid.Column="0" Style="{StaticResource StlLblForm}" Margin="0,5">Last Name:</Label>
<TextBox Grid.Row="5" Grid.Column="1" Style="{StaticResource StlTxtForm}" Text="{Binding LastName}" AcceptsReturn="True" Grid.ColumnSpan="2" Margin="0,1,0,11" />
<CheckBox Content="CopyFirstNameToLast" />
したがって、チェックボックスをオンにすると、名字に姓がレプリケートされます。コードなしでこれを行うことはできますか?はいの場合はどうですか?
あなたはonproperty notificatio変更する必要がn – ntohl
XAMLのファーストネームにファーストネームをバインドするのは簡単です(詳細はhttp://stackoverflow.com/questions/9586956/how-to-bind-a-controls-property-to-another-controls-propertyを参照してください)。 。チェックボックスを使用すると複雑になりますが、この作業を行うために値コンバーターを作成する必要があります。 –
これはおそらく何か? http:// stackoverflow。com/questions/23225751/wpf-binding-to-two-properties –