Showing posts with label slider. Show all posts
Showing posts with label slider. Show all posts

Wednesday, 12 June 2013

Wpf Slider Control


This control comes to simplify the process of coding for some UI design cases where you need to let your user choose a value and change it and you update your interface based on user's choices.  A very common example is a slider control that lets user to zoom in or zoom out to view a photo.
If you just set the Minimum and Maximum of a slider and choose a value the result is determined by the pixel position of the thumb. The value is typically a high-precision value with many decimal places. To allow only integer values you have to set the IsSnapToTickEnabled property to True.
<Slider Minimum="0"
        Maximum="20"
        IsSnapToTickEnabled="True"
        TickFrequency="2"/>

Slider is a built-in control in WPF and is easy to use.  You can have horizontal and vertical sliders with any custom interval and ticks that you like.
Here is a brief description of common properties for slider control in WPF:
  • AutoToolTipPlacement: Specifies if a ToolTip must be shown and where it will be displayed.
  • Delay: A value in milliseconds that specifies how long RepeatButton should wait before an increase or decrease.
  • Interval: a value in milliseconds that specifies the time for waiting between repeats.
  • LargeChange: The amount that should be added or subtracted to or from Value attribute when user clicks on scrollbar.
  • Maximum: Maximum value for slider.
  • Minimum: Minimum value for slider.
  • Orientation: Gets to values, Horizontal or Vertical and specifies the orientation of slider.
  • SmallChange: The amount that should be added or subtracted to or from Value attribute when user clicks on thumb.
  • TickPlacement: Determines the place that ticks should be placed.
  • Ticks: A required attribute and a set of double values for ticks.
  • Value: Default selected value for tick.