首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

UWP WinUI3 传入 AddHandler 的 RoutedEventHandler 类型与事件所需不匹配将抛出参数异常

本文记录一个 UWP 或 WinUI3 的开发过程中的问题,当开发者调用 AddHandler 时,所需的 Handler 参数类型为 RoutedEventHandler 类型,然而实际上正确类型是需要与所监听事件匹配才能符合预期工作...=> { System.Diagnostics.Debug.WriteLine("PointerPressed"); }; AddHandler...(PointerPressedEvent, handler, true); } 以上代码是能够通过构建的,原因是 AddHandler 里面的 Handler 参数就是 object 类型的。...=> { System.Diagnostics.Debug.WriteLine("PointerPressed"); }; AddHandler...(PointerPressedEvent, handler, true); 那日常开发过程中,如何知道 AddHandler 里面的 handler 参数应该传入什么类型的委托呢?

17810
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到
    领券