Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal Alignments not work for Toggle Switch #6157

Closed
1 of 2 tasks
sethuramkumar opened this issue Oct 25, 2021 · 8 comments
Closed
1 of 2 tasks

Horizontal Alignments not work for Toggle Switch #6157

sethuramkumar opened this issue Oct 25, 2021 · 8 comments
Labels
area-ToggleSwitch needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) product-winui3 WinUI 3 issues team-Controls Issue for the Controls team

Comments

@sethuramkumar
Copy link

Describe the bug

Hi Team,
In WinUI-ToggleSwitch control, Horizontal alignment is not working properly.
Refer the below code and Image:

<Grid Width="800" Height="300">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Border  BorderBrush="Red" Grid.Row="0" Grid.Column="0" BorderThickness="1 1 0 1" />
        <StackPanel Orientation="Vertical" Grid.Column="0">
            <TextBlock Text="Right Aligned" HorizontalAlignment="Center" />
            <ToggleSwitch HorizontalAlignment="Right"  />
        </StackPanel>
        <Border  BorderBrush="Red" Grid.Column="1" BorderThickness="1 1 0 1" />
        <StackPanel Grid.Column="1">
            <TextBlock Text="Left Aligned" HorizontalAlignment="Center" />
            <ToggleSwitch HorizontalAlignment="Left" Grid.Column="1"/>
        </StackPanel>
        <Border  BorderBrush="Red" Grid.Column="2" BorderThickness="1 1 0 1" />
        <StackPanel Grid.Column="2">
            <TextBlock Text="Center Aligned" HorizontalAlignment="Center" />
            <ToggleSwitch HorizontalAlignment="Center" Grid.Column="2"/>
        </StackPanel>
        <Border  BorderBrush="Red" Grid.Column="3" BorderThickness="1 1 0 1" />
        <StackPanel Grid.Column="3">
            <TextBlock Text="Without Alignment" HorizontalAlignment="Center" />
            <ToggleSwitch Grid.Column="3"/>
        </StackPanel>
        <Border  BorderBrush="Red" Grid.Column="4" BorderThickness="0 1 1 1" />
    </Grid>

Steps to reproduce the bug

Declare the ToggleSwitch control in Grid layout.
Give the Horizontal Alignment as Right.
Note the control is not fully aligned in right side.

Expected behavior

Horizontal alignment should works properly for ToggleSwitch control.

Screenshots

image

NuGet package version

WinUI 3 - Windows App SDK 0.8: 0.8.0 (If you're seeing your issue in older previews of WinUI 3, please try this release)

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

October 2020 Update (19042)

Additional context

Whether the Horizontal alignment value given or not by default the control is Aligned to left.
Please check and update on this.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 25, 2021
@JohnnyWestlake
Copy link

JohnnyWestlake commented Oct 25, 2021

Worth noting that it actually does logically work, but there's a default minimum width specified for the control that makes it optically look like it's not: <x:Double x:Key="ToggleSwitchThemeMinWidth">154</x:Double>

@StephenLPeters
Copy link
Contributor

Worth noting that it actually does logically work, but there's a default minimum width specified for the control that makes it optically look like it's not: <x:Double x:Key="ToggleSwitchThemeMinWidth">154</x:Double>

This is correct, although we should probably right align the content within that min width when the alignment is set to right...

@StephenLPeters StephenLPeters added area-ToggleSwitch needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) product-winui3 WinUI 3 issues team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Oct 25, 2021
@StephenLPeters
Copy link
Contributor

StephenLPeters commented Oct 25, 2021

You can fix this today by overriding the min width resource, however then the control wouldn't meet the recommended touch target size.

@sethuramkumar
Copy link
Author

Setting ToggleSwitch MinWidth works for the simple sample , but in my project I have used the ToggleSwitch control inside content presenter in code behind, there I can't use the key ToggleSwitchThemeMinWidth.Now, I am trying to prepare the simple sample for this. I will update once I have completed.

@sethuramkumar
Copy link
Author

Is this issue resolved with above fix?

@Diegorro98
Copy link

A year from this issue was posted and no actual fix has been released (no workarounds) 😕

@ranjeshj
Copy link
Contributor

ranjeshj commented Oct 9, 2023

ToggleSwitchThemeMinWidth seems to be the issue.

@ranjeshj
Copy link
Contributor

ranjeshj commented Oct 9, 2023

this is a dup of #3652

@ranjeshj ranjeshj closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ToggleSwitch needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) product-winui3 WinUI 3 issues team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

5 participants