Skip to content

Ugly resizing behavior for SettingsCard Header #727

@Jay-o-Way

Description

@Jay-o-Way

Describe the bug

  • SettingsCardWrapThreshold might never be reached because the minimum width of the window
  • there is no minimum width for PART_HeaderPresenter
  • HeaderPanel uses <ColumnDefinition Width="*" /> while the other columns use Auto.
  • PART_ContentPresenter has no TextWrapping property, the header and description do

Therefore the header will always give way to the content, even if you set wrapping on a textblock in the content. This combination can lead to very ugly resizing behavior.

Steps to reproduce

Use a SettingsCard with a Content with a very long piece of text that doesn't wrap (like a file path). You can set the property directly or with a TextBlock, it doesn't matter. Then resize the window, so that the width decreases. Watch the Header.

<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="SettingsCard_no_wrapping.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SettingsCard_no_wrapping"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:controls="using:CommunityToolkit.WinUI.Controls"
    Title="SettingsCard no wrapping">

    <Window.SystemBackdrop>
        <MicaBackdrop />
    </Window.SystemBackdrop>

    <Grid>
        <!-- SettingsExpander is optional -->
                <controls:SettingsCard Header="Path" Content="C:\Users\Username\Documents\SomeVeryLongFolderNameThatDoesNotWrap\AnotherVeryLongFolderNameThatDoesNotWrap\FinalFolder" />
    </Grid>
</Window>

Expected behavior

Header can shrink, but not be hidden.

Screenshots

SettingsCard Wrap Threshold

SettingsCard Wrap Fail

Code Platform

  • UWP
  • WinAppSDK / WinUI 3
  • Web Assembly (WASM)
  • Android
  • iOS
  • MacOS
  • Linux / GTK

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 10 21H2 (Build 19044)
  • Windows 10 22H2 (Build 19045)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

24H2

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Windows 10, version 2104 (Build 20348)
  • Windows 11, version 22H2 (Build 22000)
  • Other (specify)

Device form factor

Desktop

Additional context

  • Most basic: set a minimum width on the header/column?
  • (and/or) Add TextWrapping to PART_ContentPresenter ? But then ColumnWidth * will still always give way to Auto. So it wouldn't fix it.
  • Something else?

Help us help you

Yes, but only if others can assist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions