Community blog feed

WPF and "Binding to a Computed Value"

Website
Blog
Mike Taulty
Posted
12 Oct 2008 at 10:22

Summary

I was talking to Eric at FOWA about how you might be able to databind in WPF whilst applying some kind of multiplication factor. For instance you might want to do something like this; <StackPanel> <TextBlock Text="{Binding ElementName=theSlider,Path=Value}"/> <Slider x:Name="theSlider

Post extract

I was talking to Eric at FOWA about how you might be able to databind in WPF whilst applying some kind of multiplication factor.

For instance you might want to do something like this;

  <StackPanel>  
   <TextBlock Text="{Binding ElementName=theSlider,Path=Value}"/>
   <Slider x:Name="theSlider" Minimum="1" Maximum="10" MinWidth="192"/>
  </StackPanel>

except you might want to have the TextBlock display some multiple of what's in the slider.

I was about to set off trying to show how this might be done with a converter making use of the ConverterParameter when I found ( like most things ) that it was done before - specifically by Doug Stockwell up here;

http://11011.net/archives/000668.html

that post is about 2 years old so Doug's clearly a good 24 months ahead of me :-) and I've not tried his code so it might have changed on the latest version of the framework but the idea is definitely there.

Want to stay in touch with what's going on? Follow us on twitter!