Reputation: 5183
I have an interesting scenario- I have a slider that needs to update a control immediately as its value is changed. All good there, easy.
But I would ALSO like it to do some additional work, but only after a delay. The .NET 4.5 delay property on bindings would be perfect, but now the slider value needs to have two bindings... one with a delay and one without.
Something like the equivalent of this:
<Slider value={Binding Path=Property1, Delay=500; Binding Path=Property2} />
I know this doesn't exist but it would be nice to have. But is there a way to do this using the new Delay prop from 4.5?
Upvotes: 1
Views: 85
Reputation: 43596
Not sure if this will work but you could cheat a bit using MultiBinding
with a dummy converter.
Something like:
xaml:
<Window.Resources>
<local:DummyConverter x:Key="Dummyconverter" />
</Window.Resources>
<Grid>
<Slider >
<Slider.Value>
<MultiBinding Converter="{StaticResource Dummyconverter}" >
<Binding Path="Value1" />
<Binding Path="Value2" Delay="500" />
</MultiBinding>
</Slider.Value>
</Slider>
</Grid>
Dummy Converter
public class DummyConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return values == null ? null : values[0];
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
return new object[] { value, value };
}
}
Upvotes: 1