首页 > 解决方案 > Xamarin 形成未在用户控件上触发的未聚焦事件

问题描述

我基于 ContentView 创建了一个简单的 Xamarin Forms 用户控件。由于 ContentView (最终)是一个 VisualElement,我假设内置的 Unfocused 事件会按预期工作。但是,虽然我可以订阅我的用户控件的 Unfocused 事件,但该事件永远不会触发。(与 FocusChangeRequested 事件相同,事实证明。) Xamarin.Forms.VisualElement.Unfocused 事件的 Xamarin 文档是神秘的:

This event is not bubbled through the Forms stack and is received directly from the native control.

如何在 Xamarin Forms 用户控件中实现 Unfocused 事件?当用户控件失去焦点时,或者当另一个控件接收到允许我触发 Unfocused 事件的焦点时,我可以在 Xamarin Forms 环境中拦截某些东西吗?

标签: xamarin.formsuser-controls

解决方案


推荐阅读