Delay property for Binding

I’ve recently discovered a very useful property that’s been available since .NET 4.5, called Delay. It’s used in the XAML when binding a property, and it delays sending the binding back to the ViewModel for the number of milliseconds that you specify. For example…

<TextBox x:Name="TextBoxSearch"
  Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged, Delay=1000}" />

In this example, the SearchText property will not get updated as soon as the user types, but rather will wait 1 second from when the user finishes typing to update the property. This is beneficial when you have a service call, or search method that is triggered when the bound property is changed.

Here are two links that describe the usage and functionality very well:

http://www.jonathanantoine.com/2011/09/21/wpf-4-5-part-4-the-new-bindings-delay-property

https://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.delay(v=vs.110).aspx#Version%20Information

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.