Want to show value of slider in textblock?
Solution 1
The easiest would be to Bind the sliders value property to your Textblocks Text property and then you would get the value updated every time it gets changed. You could create a converter too because the Sliders Value is a double, and then with the converter you could convert this value to Int too.
Text="{Binding ElementName=YourSlider,Path=Value}"
Solution 2
Just set the TextBlock.Text with the Slider.Value.ToString() in the event fired after you stopped dragging/changing the slider.
If you want, you can also shorten the value with Math.Round():
TextBlock.Text = Math.Round(Slider.Value, [Number of Decimals]).ToString()
Regards Chris
Lavi
Updated on June 04, 2022Comments
-
Lavi almost 2 years
I'm making a windows phone 7 app and i put in a slider. It starts at 1 and ends at 80. I want to have it so when you stop the slider it shows the value of wherever the slider is in a textblock. (like if someone stops halfway, a textblock would say 40)