hi; there are Source and target textbox txttarget has a binding to txtsource. when writing something in txtsource, txttarget is changed.Everything is good. But writing on txttarget, i dont see any changes at txttarget? there is TwoWay mode. Twoway mode is not enough? can i write without using "UpdateSourceTrigger=PropertyChanged"?
<Grid>
<TextBox Height="23" HorizontalAlignment="Left" Margin="155,62,0,0" Name="txtSource" VerticalAlignment="Top" Width="120" />
<TextBox Height="23" HorizontalAlignment="Left"
Text="{Binding ElementName=txtSource,Path=Text,Mode=TwoWay}"
Margin="155,113,0,0" Name="txtTarget" VerticalAlignment="Top" Width="120" />
</Grid>
Best Answer
txtTarget.Text
is updated whenever the bound source (txtSource.Text
) changes.The binding mode is
TwoWay
which means that changes totxtTarget.Text
will be reflected to the bound source. When? It depends on theBinding.UpdataSourceTrigger
property.If you want your target binding to update your source binding when changing you must use
Binding.UpdataSourceTrigger = OnPropertyChanged
, otherwise you will update the binding source when txtTarget losts focus (default behavior).