by Sujith Chandana
WPF Range Controls
Range controls don’t render arbitrary content like content controls or items controls. They simply store and display a numeric value that falls within a specified range and basic functionality of Range Controls come from RangeBase abstract class. This class defines properties of type double that store the current value and the endpoints of the range value, Minimum, and Maximum.
ProgressBar
It is similer to the windows form’s progress bar. The default Minimum and Maximum values are 0 and 100. And there are two public properties:
<
- determinate : If this set to true, ProgressBar shows a generic animation, no matter what are the values
- Orientation : by default it is Horizontal, but can be set to Vertical to make progress go from bottom-to-top rather than left-to-right like “thermometer-style”
The Win32 ProgressBar can show a pause state and stop/error state. But WPF ProgressBar does not have built in support unfortunately.
Slider
Slider is more complicated than Progress bar because it is allows users to change values by moving its thumb. Slider also has a default Minimum of 0, but a default Maximum of 10

<Grid>
<Slider Margin="40,28,50,0" Name="slider1" Height="38"
VerticalAlignment="Top" TickPlacement="BottomRight" Maximum="15"
Cursor="Pen" AutoToolTipPlacement="BottomRight"/>
</Grid>
Slider contains several properties for adjusting the placement and frequency of ticks. One interesting feature of Slider is its support for displaying a smaller range within the current range. If IsSelectionRangeEnabled is set to true, SelectionStart and SelectionEnd can be set to the desired values of this “subrange.” with this feature, you can use this to act like the one in Windows Media Player, where a “background bar” indicates how much of the current media has been downloaded.

Slider with SubRange
Text and Ink Controls
TextBox, RichTextBox, PasswordBox, InkCanvas are the handful of controls for displaying and editing text, whether typed with a keyboard or hand-written with a stylus. You have already familiar with first three controls which mentioned above.
InkCanvas
The amazing InkCanvas is a flexible element whose primary purpose is to capture handwriting. InkCanvas is technically not a control, as it derives directly from FrameworkElement, but it acts very much like a control.
In its default mode, InkCanvas enables simple writing or drawing on its surface. When using a stylus, its tip automatically writes and its back end automatically erases. Each stroke is captured as a System.Windows.Ink.Stroke object and stored in InkCanvas’s Strokes collection. But InkCanvas also supports holding any number of arbitrary UIElements in its Children collection.
Try with this example
<Grid>
<InkCanvas Margin="40,80,67,26">
<Image Source="image.jpg"/>
</InkCanvas>
</Grid>

The SizeToContent setting is pretty interesting in this example, because if you draw out of bounds, the Window automatically resizes to fit your ink strokes if you haven’t resized it manually. InkCanvasEditingMode has following values
<!-
- Ink (default for EditingMode) : Draws strokes with the mouse or stylus
<!
- InkAndGesture : Like Ink, but also recognizes gestures made by the user. A list of gestures (such as Up, Down, Circle, ScratchOut, or Tap) can be found in the System.Windows.Ink.ApplicationGesture enumeration.
- GestureOnly : Only recognizes gestures; does not draw any strokes from user input.
- EraseByStroke (default for EditingModeInverted)—Erases an entire stroke when it is touched.
- EraseByPoint : Erases only the part of a stroke that is directly touched (like a traditional pencil eraser).
<!-
- Select : Selects strokes or any UIElements when touched, such that they can be deleted, moved, or resized within the bounds of the InkCanvas.
- None : Does nothing in response to mouse or stylus input.
By all previous articles and this we discussed about many inbuilt controls. So, next article will discuss Sizing, Positioning, and Transforming Elements in WPF.
Previous Article
Post new comment