dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.95k stars 1.7k forks source link

Switch control on Windows ignores layout and align options #10107

Open arkadym opened 1 year ago

arkadym commented 1 year ago

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

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

jinxinjuan commented 1 year ago

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Can repro on Windows platform with above project. MauiApp-17.4-1

larsduewel commented 7 months ago

Still an issue, the switch seems to have a default top, bottom margin and gets cut off as soon as you try to limit the heightrequest on windows.