OpacitySlider Control

OpacitySlider control is designed as the Opacity value selector. It’s the extension of the Slider control.

Read-write SelectedOpacity Dependency Property of the OpacitySlider control allows to get or set the value of Opacity. It’s of the double type and its value is in the [0,1] range (0 means transparent, 1 – opaque, the default).

OpacitySlider SelectedOpacity property value is synchronized with Minimum, Maximum and Value properties values of the parent Slider control. To get or set the Opacity value the caller can use both OpacitySlider and Value properties taking into account the simple relation:

SelectedOpacity = 1.0 - (Value - Minimum) / (Maximum - Minimum);

OpacitySlider control overrides the default template of the parent Slider control and looks like follows:

i.e. its style redefines the slider background and the constituent Thumb control template.

As you can see at the figure above the OpacitySlider control takes into account the parent Slider control Orientation property and can be presented as the horizontal or the vertical bar.

The direction the Opacity value changes depends on the value of IsDirectionReversed property. If it’s false (the default) the maximum opacity as at the left or at the bottom of the control depending on the orientation.

The code

You can download the code and the samples here:


The archive contains my WPFGears library with samples, tests, etc. It’s the Visual Studio 2008 SP1 solution targeted to .NET Framework 3.5.

You’ll find OpacitySliderSample project there.OpacitySlider control code is in the WPFGears library project ColorPickerControls folder.

Oleg V. Polikarpotchkin

Technorati Теги: ,,,,

About ovpwp

I am engaged in programming, maintenance and supply of computing technique since 1970. Started with the computers M, BESM, Minsk series and received appropriate education in the least, in which it was then possible in THE USSR. Then he went the usual way - ES series, IBM 360/370, Sun Spark, Ibm Power & PS2, PC. Programming started in the code (machine commands), then were sorts of assemblers, Algol, FORTRAN, PL/1, C, C , VB, C#. It is only the ones that I used the production scale; but there were, of course, others like List, Modula, Pascal, Java, etc. Currently I prefer .NET platform for desktop development. I don't really like web-programming (probably because of the inability for quality design), but I have enough experience in site building in LAMP environment using PHP.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s