0
I持っているリストボックスにバインドされたテキストボックス:リストボックスがバインドされているリストにテキストボックスの内容を追加しますバインドチェーン、観察可能なコレクションが動作していない
<TextBox Text="{Binding ElementName=PasswordsBox, Path=SelectedItem, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="1" Name="PasswordBox"/>
<ListBox ItemsSource="{Binding Processor.Passwords,ValidatesOnDataErrors=True,Mode=TwoWay}" Name="PasswordsBox" Grid.Row="1"/>
とボタン、 To:
<Button Grid.Row="1" Grid.Column="3" Command="{Binding AddPasswordCommand}" CommandParameter="{Binding Text, ElementName=PasswordBox}">+</Button>
コマンドは次のように定義されます。ここでは
_addPasswordCommand = new DelegateCommand<string>((newPass) => Processor.Passwords.Add(newPass));
は「パですモデルからの剣のコレクション
public ObservableCollection<string> Passwords
{
get
{
return _passwords;
}
set
{
if (_passwords != value)
{
_passwords = value;
OnPropertyChanged("Passwords");
}
}
}
しかし、私もテキストボックスに何かを入力することはできません。コマンドで空の要素を追加して選択すると、編集できません。
パスワードプロパティはObservableCollectionです。注:私のアプリケーションの場合、これは秘密の問題ではありません;) –
R3turnz