-
Notifications
You must be signed in to change notification settings - Fork 698
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
ToggleSwitch control internally sets a MinWidth
to 154, which is way larger than its default width
#3652
Comments
This is weird, overriding this resource should work from any parent of the toggle switch. Can you try doing it in your App.xaml? The template for toggle switch does seem weird, there should probably be a setter in the style targetting the minwidth property that sets it to this and then we should template bind the toggle switches min width to this template part. The reason that this was done is likely to maintain accessible compliant touch targets, you can see similar things with the checkbox and radio button templates, however they do the template binding thing I described above. |
It also doesn't work unfortunately. Note that I've tried to perform the override before or after referencing |
I would like to work on this. I think the @StephenLPeters proposed solution seems the best for this. |
Is this a value affected by the localisation text for On and Off? |
I don't think so. |
This still appears to be an issue, setting MinWidth to 0 does resolve it. Very odd and unexpected. |
@nkasco are you setting the property on toggle switch or the resource ToggleSwitchThemeMinWidth? |
On the Toggle Switch XAML directly: |
@nkasco what version of WinUI are you using? |
I've also found this issue with WindowsAppSDK v1.0.3. |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
I think this is still an Issue. |
Still an issue in 1.3.230724000. |
To not have the default larger MinWidth is better to set it to 0, you can control the value in 2 ways:
|
Still an issue in Windows App SDK 1.4.230822000 @mibrito707 I find that |
Describe the bug
The
ToggleSwitch
control template sets theMinWidth
of one of its internalGrid
to154
, through the following resource:Because of that, if you put a
ToggleSwitch
control in a column of aGrid
having itsColumnDefinition
width set toAuto
, the column won't adjust to the size of theToggleSwitch
by default.I tried to redefine
ToggleSwitchThemeMinWidth
resource in many places of my application to try to override it without success.Note that this issue can be mitigated with one of the following workarounds, but this is not ideal:
Width
property of theToggleSwitch
control to a fixed valueToggleSwitch
Steps to reproduce the bug
For instance, put the following XAML code in a sample page:
Expected behavior
I would expect the
ToggleSwitch
control to be aligned on the right of the grid.Screenshots
Instead, there is a lot of wasted space on the right, as you can see in the following screenshot:
Version Info
NuGet package version:
[Microsoft.UI.Xaml 2.4.3]
Windows app type:
Additional context
The text was updated successfully, but these errors were encountered: