
You can use the binding mode option to determine the directions in which data passes between the binding source and the target control. Five options are available: TwoWay. Configures the binding to be bi-directional. Changes made by the user are passed back to the data source and changes in the source update the control. This option is generally used for user input controls. OneWay. Sets the binding so that changes made in the data source are copied into the bound property of the target control. Updates made by the user are not passed to the data source. This binding mode is generally used for read-only controls, such as TextBlocks. OneWayToSource. Configures the binding so that changes made by manipulating the control are passed back to the data source. Changes in the data source are not copied into the control. OneTime. A one-time data binding means that the control’s property is set when control is created or when the data context is changed. Further changes to either the property or the data source are not transmitted. This type of binding is generally used for static data or when you wish to display a snapshot of the data at a point in time. Default. Uses the default binding mode for the property. This value varies according to the control. For example, a TextBlock’s Text property defaults to being one-way but a TextBox’s Text property uses a two-way binding as standard. We saw another type of trigger that is available called- the event trigger. As the name suggests, this trigger causes actions in response to events being raised. You can detect any routed event and respond with an action or group of actions. the event trigger is mostly used for animation effects (i.e. enlarging fonts).
We learned about the MVVM pattern (Model View View-Model). MVVM facilitates a separation of development of the graphical user interface (XAML and c# code behind) – from development of the business logic or back-end logic (the data model). when we follow the MVVM architecture we need to use the INotifyPropertyChanged. INotifyPropertyChanged is an interface used to notify the Control that the property value has changed. so if we modify a property inside an object which is Bind to the XAML, it will be updated in the view. in order to inform the UI we need to fire the PropertyChanged event (which we “get for free” when we implement this interface).
The last topic was the UI thread in WPF. when we developed a Winform application we used the async and BeginInvoke mechanism in order to call the UI thread. but before we called the UI thread we needed to check if the current thread is the UI thread or not. we can call the InvokeRequired method. if the method returns true, it means that the current thread is the UI thread. in WPF we can do the same: Dispatcher.CheckAccess() returns true if the current thread is the UI thread (and false if not). in order to ask the UI to invoke a method we use the Dispatcher.Invoke( Action ) method
More topics covered:
- SafeInvoke pattern
- MVVM – for testing purposes
- Tools like Selenium – for full end to end testing
- Model class (like person) implements the INotifyPropertyChanged
- MVVM class could be used as the DataContext of the window
Links:




