How to get Touchscreen to use Mouse Events instead of Touch Events in C# app

前端 未结 1 540
别那么骄傲
别那么骄傲 2020-12-11 09:37

I have developed a C# app that overrides the PreviewMouseUp, PreviewMouseMove, and PreviewMouseDown events in some custom controls to allow scrolling a scroll viewer by clic

相关标签:
1条回答
  • 2020-12-11 09:50

    What you can do is to use the same method for both, something like this:

    protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
    {
        OnPreviewTouchMouseUp(e);
    }
    
    protected override void OnPreviewTouchUp(TouchEventArgs e)
    {
        OnPreviewTouchMouseUp(e);
    }
    
    private void OnPreviewTouchMouseUp(EventArgs e)
    {
    
    }
    

    The only difference will be the way you get the coordinates of the mouse/touch:

    For touch:

    e.GetTouchPoint(this).Position;
    

    For mouse:

    e.GetPosition(this);
    
    0 讨论(0)
提交回复
热议问题