[UWP]滑块值

人气:498 发布:2022-09-22 标签: wpdevelop

问题描述

我希望我的滑块的值为3,5,7,9。这是我的XAML:

I'd like my slider to have the values 3,5,7,9. This is my XAML:

<Slider Minimum="3.0"
        Maximum="9.0"
        StepFrequency="2.0"
        TickFrequency="2.0"
        Value="3.0"
        TickPlacement="TopLeft"
        SnapsTo="Ticks"
        VerticalAlignment="Center" />

...而是我得到3,4,6,8,9

… but instead I get 3,4,6,8,9

如何解决?

谢谢,

Leszek

Wiki:wbswiki.com 网站: www.wisenheimerbrainstorm.com

推荐答案

@Leszek,

@Leszek,

如果您将代码修改为以下代码,您可能会理解发生了什么。

If you modify your code to the following code you may understand what happened.

  <Slider 
            Width="200"
            Minimum="2.0"
        Maximum="10.0"      
        TickFrequency="2.0"      
        SnapsTo="Ticks"
        TickPlacement="TopLeft"
        VerticalAlignment="Center" />

当您将其设置为2.0时,属性 TickFrequency似乎始终为0,2,4,6,8。当你将min值设置为3.0,最大值设置为9.0,snapsto设置为ticks时,它保持4,6,8然后再添加3,9。

It seems that the propertyTickFrequency makes the tick to be always 0,2,4,6,8 when you set it as 2.0. And as you are setting the min value as 3.0, max value as 9.0, and snapsto is set to ticks, it keeps 4,6,8 and then add 3,9 to it.

我试图在现有的属性。不幸的是,似乎没有属性可以用于此。

And I have tried to see if I can modify this behavior with the help of the existproperties.Unfortunately it seems no property can work for this.

我想您可能需要通过参考社区工具包来自定义您自己的控件源代码在这里:

I think maybe you need to customize your own control here by refer to community toolkit source code here:

https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp。 UI.Controls / RangeSelector

https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/RangeSelector

祝你好运,

Barry

296