#1,027 – Displaying a Subrange on a Slider
March 12, 2014 3 Comments
You can highlight a sub-range on a Slider that is some subset of the full range. You do this by setting the IsSelectionRangeEnabled property to true and setting SelectionStart and SelectionEnd to the desired start and end values for the range. The sub-range is displayed using a different color. Triangular indicators are displayed on the tickmark bar to show the start and end of the range.
Displaying a sub-range in this manner has no effect on the values that you’re allowed to pick with the Slider. It’s merely a visual indicator.
<Label Content="Set your Age. (Subrange is typical working age)."/> <Slider Name="mySlider" Margin="10" Foreground="Blue" Minimum="0" Maximum="100" IsSelectionRangeEnabled="True" SelectionStart="22" SelectionEnd="65" TickPlacement="BottomRight" TickFrequency="5" /> <StackPanel Orientation="Horizontal"> <Label Content="Value:" /> <TextBlock Text="{Binding Value, ElementName=mySlider, StringFormat={}{0:0}}" VerticalAlignment="Center"/> </StackPanel>
Pingback: Dew Drop – March 12, 2014 (#1741) | Morning Dew
It would be great if you would continue the slider examples with a discussion if the TickBar. The example in Microsoft docs is equivalent of using an A-Bomb to kill a flea. In particular, there must be a a way to separate the tick frequency from allowed values. For example, I want a slider to display ticks every 4 integer from 1-24 but want the use to be able to pick any integer.
Or are you not posting any more?
I haven’t tried it, but you can probably control the discrete values allowed by playing around with what you bind the Value property to, independent of tick frequency. Unfortunately, I’m not doing new posts at this time.