tags:

views:

32

answers:

1

hi there,

i´m currently facing a strange behavior with Cursors on WPF thumb controls. i have a thumb with a multibinding on the Cursor property that changes the cursor depending no the thumb´s rotationtransform angle. This works fine when i hover the mouse over the thumb. however, when i press the mouse (to do some transform) on the thumb, the cursor changes back to its original state (as long as the mouse button is down). is there something that overrides the current cursor when the mouse is pressed on a UIElement? any ideas? regards

joachim

A: 

Overriding/forcing a cursor is often done using CoerceValue. Try something like this.

FrameworkElement.CursorProperty.OverrideMetadata(
    typeof(ThumbOrMyThumbDerivedClass), 
    new FrameworkPropertyMetadata(
        null, 
        new CoerceValueCallback(MyHelperClassOrMyThumbderivedClass.CoerceCursor)));


private static object CoerceCursor(DependencyObject o, object value)
{
    if (/* conditions when to use the custom cursor */)
    {
        return CustomCursor;
    }

    return value;
}
bitbonk