wpf 觸控 觸控後無法開啟pupup

Hey,Coder!發表於2024-08-29

動態繫結觸控事件


            btnChangeErase.AddHandler(TouchDownEvent, new RoutedEventHandler(btnChangeErase_TouchDown), true);
            btnChangeErase.AddHandler(TouchUpEvent, new RoutedEventHandler(btnChangeErase_TouchUp), true);

private void btnChangeErase_TouchDown(object sender, RoutedEventArgs e)
{
    if (e is TouchEventArgs touch)
    {
        Trace.WriteLine("down");
        btnChangeErase.CaptureTouch(touch.TouchDevice);
        UpdateEraseDownTime();
    }
}

popup無法開啟解決方法

如果需要在觸控後開啟popup,需要注意延時一段時間再開啟,不然可能無法開啟popup

[參考]
一點點從坑裡爬出來:如何正確開啟 WPF 裡的 Popup?

相關文章