Slider with multiple intervals

放肆的年华 提交于 2019-12-14 00:18:01

问题


Currently, the WPF slider has some properties that allow defining and viewing a single interval on a slider: SelectionStart, SelectionEnd and IsSelectionRangeEnabled.

By setting these values

<Slider Minimum="0" Maximum="300" Value="150" IsSelectionRangeEnabled="True" SelectionStart="50" SelectionEnd="200"/>

you get the selected interval in the slider, colored in blue, like this:

What I would like to do is to be able to define multiple intervals - e.g. (50-100), (110-130), (170-200) and (210-240), which would look like this:

Any ideas on how to aproach this issue or what template I should try modifying in order to get this feature?


回答1:


this may not be an answer but a workaround. I place slider bar on canvas, then draw to canvas Highlight segments on slider bar




回答2:


Use the Ticks property to set multiple intervals. Im not sure exactly how you wanted it to work from your explaination above, but here is an example.

<Slider Minimum="0" Maximum="300" Value="150" 
IsSelectionRangeEnabled="True" SelectionStart="50" 
SelectionEnd="200" IsMoveToPointEnabled="True" 
TickPlacement="BottomRight" Ticks="50, 100, 105, 140, 150, 200" IsSnapToTickEnabled="True" />


来源:https://stackoverflow.com/questions/10086930/slider-with-multiple-intervals

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!