WPF FAQ - Slider

Find answers for the most frequently asked questions
Expand All Collapse All

You can bind two sliders, one on each of two windows and both of them linked to the same data. But they both have to be bound to the same instance of your data.

[C#]

yourDataType yourDataInstance = new YourDataType();
yourWindow1Instance.DataContext = yourDataInstance;
yourWindow2Instance.DataContext= yourDataInstance;

[XAML]

        <Window1>
           <Slider Value='{Binding ValueProperty}' />
        </Window1>
        <Window2>
            <Slider Value='{Binding ValueProperty}' />
        </Window2>

Permalink

The ticks on the slider can be customized using the code given below.

[XAML]

<Slider Width='100' Value='50' Orientation='Horizontal' HorizontalAlignment='Left' 
IsSnapToTickEnabled='True' Maximum='3' TickPlacement='BottomRight' 
AutoToolTipPlacement='BottomRight' AutoToolTipPrecision='2' 
Ticks='0, 1.1, 2.5, 3'/>

Permalink

Share with

Couldn't find the FAQs you're looking for?

Please submit your question and answer.