Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Window x:Class="DataBinding.MyWindow" ...
- Title="MyWindow" Height="300" Width="300">
- <StackPanel x:Name="TopLevelContainer">
- <TextBox x:Name="txtValue" Background="AliceBlue" Text="{Binding Path=MyDotNetProperty}" />
- <TextBlock TextWrapping="Wrap">We're twin blue boxes bound to the same property.</TextBlock>
- <TextBox x:Name="txtValue2" Background="AliceBlue" Text="{Binding Path=MyDotNetProperty}" />
- </StackPanel>
- </Window>
- public partial class MyWindow : Window, INotifyPropertyChanged
- {
- public MyWindow()
- {
- InitializeComponent();
- this.MyDotNetProperty = "Go ahead. Change my value.";
- TopLevelContainer.DataContext = this;
- }
- private string m_sValue;
- public string MyDotNetProperty
- {
- get { return m_sValue; }
- set
- {
- m_sValue = value;
- if (null != this.PropertyChanged)
- {
- PropertyChanged(this, new PropertyChangedEventArgs("MyDotNetProperty"));
- }
- }
- }
- #region INotifyPropertyChanged Members
- public event PropertyChangedEventHandler PropertyChanged;
- #endregion
- }
Add Comment
Please, Sign In to add comment