RangeBase Class in WPF

Introduction

This article explains the rangebase class that is the only base class for the WPF information controls.

  • It defines members for controls that display a single value, that falls within a given range. One such control is the ProgressBar.
  • RangeBase is also used by interactive controls that permit the value to be changed by the user. These include the ScrollBar and Slider controls.

Background

There are five key properties supplied by RangeBase, three of which were described in the ProgressBar article. The two other properties are used by interactive controls, for this article we'll just list the properties and their uses.

Solution and Procedure

Value.

The Value property allows you to get or set the current value that is represented by the control. The value is a double-precision floating-point number.

Minimum

The Minimum property sets the smallest value in the range that the control can display.

Maximum

The Maximum property sets the largest value in the range that the control can display.

SmallChange

The SmallChange value can only be used in controls that are interactive. It has no effect with the ProgressBar class. SmallChange determines the amount that will be added or subtracted from the Value property in response to certain user actions.  For example, this is the change applied when the user clicks one of the arrows at the end of a scroll bar. Setting this property does not prevent the user from making larger or smaller changes.

LargeChange

The LargeChange value is similar to SmallChange but it is used for various user actions. For example, this is the amount added or subtracted from Value when the user clicks the track section of a scroll bar.

Event

The RangeBase class also defines a useful event. ValueChanged is raised when the Value property changes. The event arguments for the event include the old and the new values.

Up Next
    Ebook Download
    View all
    Learn
    View all