Oleg's profileOleg V. Polikarpotchkin ...BlogNetwork Tools Help

Blog


    June 06

    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:

    OpacitySlider

    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.


    Regards,
    Oleg V. Polikarpotchkin

    Technorati Теги: ,,,,

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://ov-p.spaces.live.com/blog/cns!39D56F0C7A08D703!280.trak
    Weblogs that reference this entry
    • None