-
Name the control, e.g.,
<RadioButton x:Name="male"/>
. -
In the handling class, reference the
using Microsoft.Maui.Handlers;
namespace, and add property control code in theNavigatedTo
method.1 2 3 4 5 6 7 8 9 10 11 12 13 14
#if WINDOWS IRadioButtonHandler? handler = radioButtonMale.Handler as RadioButtonHandler; if (handler != null) { handler.PlatformView.IsTabStop = true; handler.PlatformView.UseSystemFocusVisuals = true; } IRadioButtonHandler? handlerf = radioButtonFemale.Handler as RadioButtonHandler; if (handlerf != null) { handlerf.PlatformView.IsTabStop = true; handlerf.PlatformView.UseSystemFocusVisuals = true; } #endif
-
In the
OnAppearing
method, use the Loaded event to set properties and execute methods.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
protected override void OnAppearing() { base.OnAppearing(); number.Loaded += delegate { number.Focus(); }; male.Loaded += Male_Loaded; female.Loaded += Female_Loaded; } private void Female_Loaded(object? sender, EventArgs e) { #if WINDOWS IRadioButtonHandler? handler = female.Handler as RadioButtonHandler; if (handler != null) { handler.PlatformView.IsTabStop = true; handler.PlatformView.UseSystemFocusVisuals = true; } #endif } private void Male_Loaded(object? sender, EventArgs e) { #if WINDOWS IRadioButtonHandler? handler = male.Handler as RadioButtonHandler; if (handler != null) { handler.PlatformView.IsTabStop = true; handler.PlatformView.UseSystemFocusVisuals = true; } #endif }