Posts

Showing posts with the label WPF TextBox MVVM DataBinding UpdateSourceTrigger PropertyChanged

WPF TextBox MVVM DataBinding & use of UpdateSourceTrigger

If you are using a TextBox in your WPF application with MVVM pattern & want to keep the TextBox Text and the property in the ViewModel synchronized, you need to use UpdateSourceTrigger=PropertyChanged in the binding. Here is an example: View XAML: < Window  x : Class ="WPF.MainWindow"            xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns : x ="http://schemas.microsoft.com/winfx/2006/xaml"            Title ="WPF TextBox MVVM DataBinding Example"  Height ="500"  Width ="500">      < Grid >          < TextBox  Text ="{ Binding  Path =Name,  UpdateSourceTrigger =PropertyChanged,  Mode =TwoWay}"  Height ="25" />      Grid > Window > View Code Behind: usi...