Switches Radiobuttons

This commit is contained in:
2025-08-18 08:35:23 +02:00
parent ebbea4c1d4
commit e50f9c25b7
2 changed files with 40 additions and 3 deletions

View File

@ -21,6 +21,7 @@ namespace AdventureWorks.MAUI
#if WINDOWS #if WINDOWS
SetWindowOptions(builder); SetWindowOptions(builder);
SetWindowHandlers();
#endif #endif
#if DEBUG #if DEBUG
@ -53,5 +54,20 @@ namespace AdventureWorks.MAUI
}); });
} }
#endif #endif
#if WINDOWS
public static void SetWindowHandlers()
{
// Customize the Switch control for Windows
Microsoft.Maui.Handlers.SwitchHandler.Mapper
.AppendToMapping("Custom", (h,v) =>
{
h.PlatformView.OffContent = "No";
h.PlatformView.OnContent = "Yes";
h.PlatformView.MinWidth = 0;
});
}
#endif
} }
} }

View File

@ -7,7 +7,7 @@
<Border Style="{StaticResource Border.Page}"> <Border Style="{StaticResource Border.Page}">
<ScrollView> <ScrollView>
<Grid RowDefinitions="Auto, Auto, Auto, Auto,Auto, Auto, Auto , Auto" <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto,Auto, Auto, Auto , Auto"
ColumnDefinitions="Auto, *" ColumnDefinitions="Auto, *"
Style="{StaticResource Grid.Page}"> Style="{StaticResource Grid.Page}">
@ -66,10 +66,31 @@
</HorizontalStackLayout> </HorizontalStackLayout>
</FlexLayout> </FlexLayout>
<partial:AddressView Grid.Row="6" <Label Grid.Row="6"
Text="Still Employed"/>
<Switch Grid.Row="6"
Grid.Column="1"/>
<Label Text="Employee Type"
Grid.Row="7"/>
<FlexLayout Grid.Row="7"
Grid.Column="1"
Wrap="Wrap"
Direction="Row">
<HorizontalStackLayout>
<Label Text="Full-Time"/>
<RadioButton IsChecked="True"
GroupName="EmployeeType"/>
</HorizontalStackLayout>
<HorizontalStackLayout>
<Label Text="Part-Time"/>
<RadioButton GroupName="EmployeeType"/>
</HorizontalStackLayout>
</FlexLayout>
<partial:AddressView Grid.Row="8"
Grid.ColumnSpan="2" /> Grid.ColumnSpan="2" />
<HorizontalStackLayout Grid.Row="7" <HorizontalStackLayout Grid.Row="9"
Grid.Column="1" Grid.Column="1"
Spacing="5"> Spacing="5">
<Button Text="Save" /> <Button Text="Save" />