.Net 4.5 ‘Delay’ Binding property

‘Delay’ is one of the coolest property which is introduced as a part of the series on WPF 4.5 new features.

As pointed out by MSDN, If you use a data binding to update a data source, you can use the Delay property to specify an amount of time to pass after the property changes on the target before the source updates. For example, suppose that you have a Slider that has its Value property data two-way bound to a property of a data object and the UpdateSourceTrigger property is set to PropertyChanged. In this example, when the user moves the Slider, the source updates for each pixel that the Slider moves. The source object typically needs the value of the slider only when the slider’s Value stops changing. To prevent updating the source too often, use Delay to specify that the source should not be updated until a certain amount of time elapses after the thumb stops moving.

<Window x:Class="WpfApplication6.MainWindow"
            <Slider x:Name="ValueSlider"
                    Value="{Binding ElementName=ValueText, Delay=500, Path=Text,Mode=TwoWay}" />
            <TextBox x:Name="ValueText"
                     HorizontalAlignment="Center" />

Again, it’s a discrete addition to the WPF framework but it’s a useful one !


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s