binding mode, trigger
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
<StackPanel>
|
||||
<Label HorizontalAlignment="Center">--- By XAML Code ---</Label>
|
||||
<TextBox x:Name="tbxByXaml" VerticalAlignment="Center"/>
|
||||
<Label x:Name="lblByXaml" Height="30" VerticalAlignment="Center" Content="{Binding ElementName=tbxByXaml, Path=Text}"/>
|
||||
<TextBox x:Name="tbxByXaml2" Height="30" VerticalAlignment="Center" Text="{Binding ElementName=tbxByXaml, Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<Label HorizontalAlignment="Center">--- By Code Behind ---</Label>
|
||||
<TextBox x:Name="tbxByCodeBehind"/>
|
||||
<Label x:Name="lblByCodeBehind" Height="30" VerticalAlignment="Center"/>
|
||||
<TextBox x:Name="tbxByCodeBehind2" Height="30" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
@@ -31,7 +31,9 @@ namespace DataBindingSample
|
||||
Binding binding = new Binding();
|
||||
binding.Source = tbxByCodeBehind;
|
||||
binding.Path = new PropertyPath(TextBox.TextProperty);
|
||||
lblByCodeBehind.SetBinding(Label.ContentProperty, binding);
|
||||
binding.Mode = BindingMode.TwoWay;
|
||||
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
|
||||
tbxByCodeBehind2.SetBinding(TextBox.TextProperty, binding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user