I have multitasking that looks something like this:
<UserControl.Visibility> <MultiBinding Converter="{StaticResource isMouseOverToVisibiltyConverter}"> <Binding ElementName="otherElement" Path="IsMouseOver" /> <Binding RelativeSource="{RelativeSource Self}" Path="IsMouseOver" /> </MultiBinding> </UserControl.Visibility>
And I want to be able to add a delay between IsMouseOver going to false for both bindings and for the Visibility parameter set to Collapsed.
I found this implementation of DelayBinding: http://www.paulstovell.com/wpf-delaybinding
But this does not work for MultiBinding, and I could not figure out how to create one that works with MultiBinding.
I have the ability to make changes to Visibility in events in the code, and this will work, but it would be nice if there was some way to do this through the binding system.
Is there any way to add delay to MultiBinding?
EDIT: Ray, in order to get my class to compile and run, I had to make some corrections. However, something is still wrong as updates are not distributed. It seems that only once updates the target property.
[ContentProperty("Bindings")] public class DelayedMultiBindingExtension : MarkupExtension, IMultiValueConverter, INotifyPropertyChanged { public Collection<BindingBase> Bindings { get; private set; } public IMultiValueConverter Converter { get; set; } public object ConverterParameter { get; set; } public CultureInfo ConverterCulture { get; set; } public BindingMode Mode { get; set; } public UpdateSourceTrigger UpdateSourceTrigger { get; set; } public object CurrentValue { get { return _delayedValue; } set { _delayedValue = _undelayedValue = value; _timer.Stop(); } } private object _undelayedValue; private object _delayedValue; private DispatcherTimer _timer; public int ChangeCount { get; private set; }
EDIT2: Despite the fact that I could not get the Ray code to work, I marked it as an answer because it brought me code that really works. See my answer below for the code I used.
wpf multibinding
Ashley
source share