BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Windows Presentation Foundation
.NET 4.0+

WPF Base Classes - RangeBase

The forty-seventh part of the Windows Presentation Foundation Fundamentals tutorial looks at the RangeBase class. This is a base class for WPF controls, including one of the information controls described earlier in the tutorial.

RangeBase

The RangeBase class is the only base class for the WPF information controls that we haven't already examined earlier in the tutorial. It defines members for controls that display a single value, which 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, which we shall see in future articles.

Properties

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, so we'll see them in a later instalment of the WPF tutorial. For this article we'll just list the properties and their use:

  • 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 is only of use 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 different 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.

28 January 2014