SIGN UP MEMBER LOGIN:    
ARTICLE

Silverlight- Slider Control Part 1

Posted by Vijai Anand Articles | Silverlight December 05, 2010
In this article we will be seeing how to create Silverlight Slider control.
Reader Level:

In this article we will be seeing how to create Silverlight Slider control.

Slider Control is used to allow the user to select from a range of values by moving the Thumb control.

Namespace:
System.Windows.Controls

Assembly: System.Windows (in System.Windows.dll)

Xaml:

        <Slider></Slider>

Slider with horizontal orientation:

By default the orientation property will be Horizontal.

Slider1.gif

<Canvas Background="Orange"
            Height="200"
            Width="200"
            Opacity="0.6">
        <Slider x:Name="slider"
                Background="Green"
                Height="25"
                Width="150"
                Canvas.Left="27"
                Canvas.Top="84" >
        </Slider>
    </Canvas>

Slider with vertical orientation:

Slider2.gif

<Canvas Background="Orange"
            Height="200"
            Width="200"
            Opacity="0.6">
        <Slider x:Name="slider"
                Background="Green"
                Height="150"
                Width="25"
                Canvas.Left="87"
                Canvas.Top="24"
                Orientation="Vertical">
        </Slider>

    </Canvas>

Slider with IsDirectionReversed:

Slider3.gif

<Canvas Background="Orange"
            Height="200"
            Width="200"
            Opacity="0.6">
        <Slider x:Name="slider"
                Background="Green"
                Height="25"
                Width="150"
                Canvas.Left="27"
                Canvas.Top="84"
                IsDirectionReversed="True">
        </Slider>
    </Canvas>

Slider with ValueChanged event:

<Canvas Background="Orange"
            Height="200"
            Width="230"
            Opacity="0.6">
        <Slider x:Name="slider"
                Background="Green"
                Height="25"
                Width="150"
                Canvas.Left="27"
                Canvas.Top="84"
                Minimum="0"
                Maximum="100"
                ValueChanged="slider_ValueChanged">
        </Slider>
        <TextBlock  Height="25" Width="50" Foreground="Blue" Text="Slider Value:" Canvas.Left="27" Canvas.Top="65"></TextBlock>
        <TextBlock x:Name="txtSliderValue" Height="25" Width="50" Foreground="Blue"  Canvas.Left="100" Canvas.Top="65"></TextBlock>
    </Canvas>

ValueChanged event:

private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            txtSliderValue.Text = e.NewValue.ToString();
        }


Minimum="0":

It is used to specify the minimum possible Value of the range element.

Slider4.gif

Maximum="100":

It is used to specify the maximum possible value of the range element.

Slider5.gif

Changing the Slider value:

Slider6.gif

share this article :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor