Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

WPF Slider Control

Article:
Viewed:  1719 
Posted On:  26/11/2013 10:34:41 
How we can use slider control in WPF ? 

A Slider has a minimum and a maximum. It has a button that a user can drag back and forth.


 
Minimum: get or set the minimum value of the control. By default it is zero.
 Maximum: get or set the maximum value of the control. By default it is Ten.
 Value: get or set the current value of the control. By default it is zero.

XAML Code:

<Window x:Class="SliderControl.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Slider Control in WPF" Height="300" Width="300">
    <Grid>
        <Slider HorizontalAlignment="Left"
                        Margin="20,30,0,0"
                        VerticalAlignment="Top"
                        Width="250"
                        ValueChanged="Slider_ValueChanged"/>
        <TextBlock Height="21" Margin="21,82,27,0" Name="txtSliderPosition" VerticalAlignment="Top" />
    </Grid>
</Window>

Here on using slider I am showing slider current value in a TextBlock for this my cade is:

private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
        var slider = sender as Slider;
        double value = slider.Value;
        txtSliderPosition.Text = "Value: " + value.ToString("0.0") + "/" + slider.Maximum;
}

Output:

Slider In WPF 1.png

Image 1.

When you use slider...

Slider In WPF 2.png

Image 2.

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us