Wrong ticks in XAML slider


  • Hi,

    I'm working on a C++ app where I'd like to use a slider. This is the XAML code:

    <Slider x:Name="slider_count" Width="200" Minimum="0" Value="1000" Maximum="100000" StepFrequency="100" TickFrequency="1000" />

    Nothing that special, I suppose. Anyway, something is going wrong: I expected 10 ticks, one per 1000 "units". But what I do get are 5 ticks per 2000 units as shown in the following screenshot:

    Am I doing something wrong or is this a bug?



    Thursday, February 28, 2013 1:40 PM


  • Hello,

    This behavior appears to be normal as per MSDN documentation: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.slider.tickfrequency.aspx

    "To prevent tick marks from being packed too densely, the Slider will only show tick marks that are a minimum of 20 pixels apart. If a combination of Slider size, value range,  and tick frequency results in tick marks that are too close together, some tick marks are not shown. "

    If you increase the width of your slider control, you should be able to see tick marks at every 1000 units. So, if you care about the tick marks, then increase the size of the slider control to show the ticks at every 1000 units.

    Btw, in your sample xaml above the maximum value should be 10000 and not 100000 to match with the screenshot.



    Friday, March 1, 2013 7:50 PM