A couple weekends back, I was giving a talk on the .NET
Gadgeteer, and spoke about the support for Potentiometers. Unlike
some of the other modules, a potentiometer (like the volume knob on
a stereo) varies so much in use that you wouldn't want to raise an
event for every little change. The solution in electronics is
typically to poll the pot to find its current value.
Similar situations exist in XAML binding. Consider a scrollbar
or slider. You may not want to send update notifications to the
binding system for every micro movement of the slider as the user
is sliding it from one side of the screen to the other. Instead,
you may want to update only after a delay.
<Window x:Class="WpfBindingDelay.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<StackPanel>
<Slider x:Name="ValueSlider"
Minimum="0" Maximum="100"
Margin="20" Height="25"
Value="{Binding ElementName=ValueText, Delay=500, Path=Text, Mode=TwoWay}" />
<TextBox x:Name="ValueText" Text="50"
Width="100" Height="50" FontSize="20"
HorizontalAlignment="Center" />
</StackPanel>
</Grid>
</Window>
The delay time is specified in milliseconds. In this case, I've
specified 500ms (1/2 second) after the last update, to make the
delay really obvious. This isn't a polling interval; the timer
kicks in when you stop making changes. Normally you wouldn't use a
value as large as 500, of course :)
Where you put the delay also has an impact. For example, if you
bound the two controls together inside the TextBox's Text property
and put the delay there, it wouldn't affect slider changes, only
changes to the value typed into the TextBox.
Another useful place for this is when binding to data in a
TextBox where you want to catch incremental changes, but the cost
(for example, a search) is somewhat expensive. In that case, you
can wait for a slight pause, maybe 100ms between keystrokes, and
perform your search then.