Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

change Style in WPF Slider

Hi,

does anyone know how to change a the Style of the standart Slider ? For example i want another scrollbar and another scroll-color.

Thanks

Manuel

0 Kudos
Message 1 of 7
(10,078 Views)

If by "standard Slider" you mean the Microsoft Slider control, I would start with the Slider Styles and Templates page on MSDN.


If instead you mean the Measurement Studio Slider<TData> control, I will need to know more about what you mean by "another scrollbar and another scroll-color" to help.

~ Paul H
0 Kudos
Message 2 of 7
(10,062 Views)

Hi Paul,

sorry for my late Answer. I mean the Measurement Studio SliderDouble.

 

I have an Example.

My Slider looks like

sliderMS.png

And the Thumb in my Slider looks like

ThumbMS.png

 

But i want that my Slider or only my Thumb looks like the following One

ThumbWish.png

 

Is this possible ?

 

0 Kudos
Message 3 of 7
(10,024 Views)

If all you need is a different visual for the pointer, you can use the PointerTemplate property:


    <ni:SliderDouble Height="200" Width="40" ScaleLocation="Far" Orientation="Vertical">
        <ni:SliderDouble.PointerTemplate>
            <DataTemplate>
                <Grid niPrimitives:RegionPanel.RelativeHeight="1.0"
                      niPrimitives:RegionPanel.RelativeHorizontalPosition="{Binding RelativeValue}"
                      niPrimitives:RegionPanel.RelativeHorizontalAlignment="Center"
                      niPrimitives:RegionPanel.LayoutOptions="ExcludeOverhang"
                      MinWidth="11">
                    <Path Data="M 1,0 L 2,1 2,2 0,2 0,1 Z"
                          Stretch="Fill"
                          Fill="{Binding PointerBrush}"
                          Stroke="{BindingBorderBrush}"
                          StrokeThickness="1" />
                </Grid>
            </DataTemplate>
        </ni:SliderDouble.PointerTemplate>
    </ni:SliderDouble>



Please note that this mockup relies on implementation details of the current release of the WPF controls. We intentionally left many of the underlying primitive types with minimal documentation, as we may change them in the future. In the current implementation, we use RegionPanels to perform the layout for many of our controls. Although these exact members may be removed in a later release, we do plan to provide equivalent functionality and stabilize the primitive API over time.


Besides that caveat, I hope you find this useful.

~ Paul H
0 Kudos
Message 4 of 7
(10,019 Views)

Thank you Paul, that helped me a lot.

I've one more Question. I'm not sure if i should open a new Thread.

I have a slider with 12 Values. But i want to change the Size and not all Values shows up. How can i change the distance between the Values so that all Values shows up ?

slider_size_Problem.png

0 Kudos
Message 5 of 7
(10,012 Views)

For future reference, it would be more useful for tracking purposes to open a separate thread.


The answer to your question is simple, though: the Mode property on the MajorDivisions for the scale controls which values are displayed. For example, using an interval mode will force all the whole numbers in the range to be displayed:


    <ni:SliderDouble Range="1, 12, System.Double" >
        <ni:SliderDouble.Scale>
            <ni:NumericScale>
                <ni:NumericScale.MajorDivisions>
                    <ni:RangeLabeledDivisions Mode="Interval: 0, 1" />
                </ni:NumericScale.MajorDivisions>
            </ni:NumericScale>
        </ni:SliderDouble.Scale>
    </ni:SliderDouble>

~ Paul H
0 Kudos
Message 6 of 7
(10,006 Views)

Great, that was exactly what i need.

Thanks a lot.

Manuel

0 Kudos
Message 7 of 7
(10,004 Views)