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
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor