There is an important concept provided in WPF, which is Data binding. This allows you to wire-up UI controls to a business model in Application. When a binding is established and the data or your business model have some changes, then it reflects the updates automatically to the UI elements and vice versa which totally depends on the type of binding used in XAML.
Types of Binding support by WPF
- OneWay
- TwoWay
- OneWayToSource
- OneTime
The Data binding is done between two objects, the source (where the value comes from) and the target (where the value goes to). This performs synchronization between two properties. If and only if the binding is done in TwoWay mode then the target is able to update the source value
Delay in Data Bindings
This reflection is done immediately on each change of the target value, even a tiny change too. So you wouldn't want to raise an event or send update notifications for every little change, you just want to update this only after a delay or timespan. Then you should use the Delay keyword in Binding markup extension (XAML).
- <StackPanel>
- <Slider x:Name="Slider"
- Minimum="0" Maximum="100"
- Margin="10 40 10 20 " Height="25"
- Value="{Binding ElementName=SliderValue,Path=Text, Delay=1000, Mode=TwoWay}" />
- <TextBox x:Name="SliderValue" Text="50" TextAlignment="Center" HorizontalAlignment="Center"
- Width="200" Height="30" FontSize="20" />
-
- </StackPanel>
Here, I have set a value of delay property as 1000 milliseconds, Due to this, it performs a 1 second delay in data binding reflection.