Skip to content

Instantly share code, notes, and snippets.

@Patrick84
Created March 21, 2015 19:47
Show Gist options
  • Save Patrick84/24996627898927cee831 to your computer and use it in GitHub Desktop.
Save Patrick84/24996627898927cee831 to your computer and use it in GitHub Desktop.
Two Textboxes bound to each other in XAML. If the Text of the first Textbox is changed, the second one will also change.
<Window x:Class="BindingExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox x:Name="tb1" HorizontalAlignment="Left" Height="23" Margin="102,80,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="tb2" HorizontalAlignment="Left" Height="23" Margin="282,80,0,0" TextWrapping="Wrap" Text="{Binding Text, ElementName=tb1, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="120"/>
</Grid>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment