Junior — Middle
Can you name the main types of data binding used in WPF?
sobes.tech AI
Answer from AI
In WPF, the main types of data binding include:
- OneWay — data is transferred only from the source to the receiver. Changes in the source are reflected in the UI, but not vice versa.
- TwoWay — two-way binding. Changes in the UI update the source, and vice versa.
- OneWayToSource — data is transferred only from the UI to the source.
- OneTime — data is transferred once during initialization; further changes are not tracked.
Example of TwoWay binding in XAML:
<TextBox Text="{Binding Path=UserName, Mode=TwoWay}" />
Here, the UserName property from the data model will be synchronized with the text in the TextBox in both directions.