Skip to content

Switch control on Windows ignores layout and align options #10107

@arkadym

Description

@arkadym

Description

Switch control do not reflect options for sizing and aligning. With latest MAUI/VS17.3/VS17.4 is just still not possible to set On/Off text, disable text, set width/height (even using MaximumWidthRequest/MaximumHeightRequest) in Windows.
Here is test layout (see attached source codes)

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp1.NewPage1"
             Title="NewPage1">
    
    <Grid RowSpacing="10" ColumnSpacing="10" RowDefinitions="40,60,60,60,40" ColumnDefinitions="Auto,42,*" BackgroundColor="#555">
        <Label Text="Expiry" VerticalOptions="Center" BackgroundColor="Red" />
        <Label Grid.Row="1" Text="OTP" VerticalOptions="Center" BackgroundColor="Brown" />
        <Label Grid.Row="2" Text="Share with View only" VerticalOptions="Center" />
        <Label Grid.Row="3" Text="Notifications" VerticalOptions="Center" />
        <Label Grid.Row="4" Text="No. of attempts Allowed" VerticalOptions="Center" />

        <Switch Grid.Column="1" VerticalOptions="Center" BackgroundColor="Blue" />
        <Frame Grid.Row="1" Grid.Column="1" VerticalOptions="Fill" BackgroundColor="Cyan" Padding="0" BorderColor="Transparent" CornerRadius="0">
            <Switch VerticalOptions="Center" BackgroundColor="LightPink" WidthRequest="40" MaximumWidthRequest="40" />
        </Frame>
        <HorizontalStackLayout  Grid.Row="2" Grid.Column="1" BackgroundColor="AliceBlue">
            <Switch VerticalOptions="Start" BackgroundColor="LightBlue" />
        </HorizontalStackLayout>
        <Switch Grid.Row="3" Grid.Column="1" VerticalOptions="Center" BackgroundColor="Lime" HeightRequest="20" />
        <Frame  Grid.Row="4" Grid.Column="1" VerticalOptions="Center" HeightRequest="20" BorderColor="Transparent" Padding="0" CornerRadius="0">
            <Switch VerticalOptions="Center" />
        </Frame>

        <HorizontalStackLayout Grid.Column="2" VerticalOptions="Center" Spacing="5" BackgroundColor="Aquamarine">
            <RadioButton Content="Immediate" />
            <RadioButton Content="Summary" />
        </HorizontalStackLayout>

        <HorizontalStackLayout Grid.Column="2" Grid.Row="4" VerticalOptions="Center" Spacing="3">
            <Button WidthRequest="16" HeightRequest="16" Text="-" VerticalOptions="Center" Padding="0,0,0,1" CornerRadius="2" BorderWidth="0"
                    BackgroundColor="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Tertiary}}"
                    TextColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Tertiary}}"/>
            <Entry WidthRequest="40" MaxLength="2" />
            <Button WidthRequest="16" HeightRequest="16" Text="+" VerticalOptions="Center" Padding="0,0,0,1" CornerRadius="2" BorderWidth="0"
                    BackgroundColor="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Tertiary}}"
                    TextColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}"/>
        </HorizontalStackLayout>
    </Grid>
</ContentPage>

image
Row 3 - somehow Switch appeared behind the column edge
Rows 4 and 5 - attempt to limit height of the Switch control

Steps to Reproduce

Use attached source codes and run it on Windows 10/11

Link to public reproduction project repository

https://github.com/arkadym/MAUI-Bugs/tree/master/MauiApp-17.4-1

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 10 and Windows 11

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-switchSwitcharea-layoutStackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenterp/2Work that is important, but is currently not scheduled for releasepartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/windowss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions