void OnFocusedChange(bool hasFocus) { if (TypedNativeView == null || VirtualView == null) { return; } // This will eliminate additional native property setting if not required. if (VirtualView.ClearButtonVisibility == ClearButtonVisibility.WhileEditing) { TypedNativeView?.UpdateClearButtonVisibility(VirtualView, ClearButtonDrawable); } }
void OnTextChanged(string?text) { if (VirtualView == null || TypedNativeView == null) { return; } // Even though <null> is technically different to "", it has no // functional difference to apps. Thus, hide it. var mauiText = VirtualView.Text ?? string.Empty; var nativeText = text ?? string.Empty; if (mauiText != nativeText) { VirtualView.Text = nativeText; } // Text changed should trigger clear button visibility. TypedNativeView.UpdateClearButtonVisibility(VirtualView, ClearButtonDrawable); }