开发者

Strange WPF Thumb Cursor behavior

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, th开发者_如何学运维e 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


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜