partial void UpdateKeyboardThemePartial() { if (_textBoxView == null) { return; } // if KeyboardAppearance has been explicitly set, we leave it as is. if (KeyboardAppearance != UIKeyboardAppearance.Default) { return; } ElementTheme?GetExplicitlySetAppTheme() => Application.Current.IsThemeSetExplicitly ? Application.Current.ActualElementTheme as ElementTheme? : null; // the appearance will be determined by the first parent/self that has a non-default RequestedTheme, // or the explicitly requested application theme. // note: the literal "Default" value is lost on the ActualTheme property, which is why we are not using it here. var theme = VisualTreeHelper.EnumerateAncestors(this).OfType <FrameworkElement>() .Prepend(this) .Select(x => x.RequestedTheme as ElementTheme?) .Append(GetExplicitlySetAppTheme()) .FirstOrDefault(x => x != ElementTheme.Default); var appearance = theme switch { ElementTheme.Light => UIKeyboardAppearance.Light, ElementTheme.Dark => UIKeyboardAppearance.Dark, _ => UIKeyboardAppearance.Default }; _textBoxView.KeyboardAppearance = appearance; } }