void OnLoaded(object sender, UI.Xaml.RoutedEventArgs e) { _queryTextBox = NativeView?.GetFirstDescendant <MauiTextBox>(); _cancelButton = _queryTextBox?.GetFirstDescendant <MauiCancelButton>(); if (_cancelButton != null) { if (_defaultDeleteButtonBackgroundColorBrush == null) { _defaultDeleteButtonBackgroundColorBrush = _cancelButton.Background; } if (_defaultDeleteButtonForegroundColorBrush == null) { _defaultDeleteButtonForegroundColorBrush = _cancelButton.Foreground; } // The Cancel button's content won't be loaded right away (because the default Visibility is Collapsed) // So we need to wait until it's ready, then force an update of the button color _cancelButton.ReadyChanged += (o, args) => { if (VirtualView != null) { NativeView?.UpdateCancelButtonColor(VirtualView, _cancelButton, _defaultDeleteButtonBackgroundColorBrush, _defaultDeleteButtonForegroundColorBrush); } }; } if (VirtualView != null) { NativeView?.UpdateHorizontalTextAlignment(VirtualView, _queryTextBox); NativeView?.UpdateMaxLength(VirtualView, _queryTextBox); } }