Skip to content

Pivot control text wrapping fails with TextBox/RichEditBox/TextBlock on Desktop/Skia #21729

Closed

Description

@terrycox

Current behavior 🐛

Text wrapping does not work correctly for TextBox, RichEditBox, and TextBlock controls placed within PivotItem content on Desktop (Skia) and WASM platforms. Text extends beyond the visible area horizontally instead of wrapping, even when TextWrapping="Wrap" and MaxWidth properties are set. The same XAML content works correctly when using TabView instead of Pivot.

Important: This issue does NOT occur on WinAppSDK head - it's specific to Desktop/Skia and WASM heads.

This issue was discovered while developing [StoryCAD](https://github.com/storybuilder-org/StoryCAD) on the Desktop head (net9.0-desktop) for cross-platform support, where switching from Pivot to TabView immediately resolved all text wrapping issues without any other code changes.

Expected behavior 🎯

Text content within Pivot control should wrap correctly, respecting TextWrapping="Wrap" and MaxWidth properties, the same way it does in TabView and other container controls.

How to reproduce it (as minimally and precisely as possible) 🔬

Minimal Repro Project

See attached files in /text-wrapping-issue/ folder:

  • PivotTextWrappingIssue.xaml - Demonstrates the issue
  • TabViewTextWrappingCorrect.xaml - Shows correct behavior with TabView
  • MainPage.xaml - Allows switching between both examples

Steps to Reproduce

  1. Create a new UNO Platform application targeting Desktop (net9.0-desktop)
  2. Add a Pivot control with multiple PivotItems
  3. Place TextBox controls with TextWrapping="Wrap" and MaxWidth="600" in PivotItems
  4. Add long text content that should wrap
  5. Run on Desktop/Skia platform: dotnet run -f net9.0-desktop
  6. Observe that text does not wrap and extends horizontally beyond boundaries
  7. Replace Pivot with TabView and observe correct wrapping behavior

Example XAML (Simplified)

Workaround 🛠️

Replace Pivot control with TabView, which handles text wrapping correctly. This is a complete solution for most use cases, as TabView provides a similar tabbed interface.

text-wrapping-issue.zip

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

Desktop (macOS)

Uno.Sdk version (and other relevant versions) 📦

6.3.28

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

Root Cause Analysis

The issue appears to be related to the Pivot control template's use of ScrollViewer around the entire content area. The template contains:

<ScrollViewer x:Name="ScrollViewer"
    HorizontalScrollBarVisibility="Hidden"
    VerticalScrollMode="Disabled"
    VerticalScrollBarVisibility="Disabled">
    <!-- Content with measurement issues -->
</ScrollViewer>

This is likely a consequence of the workaround for issue #3596 (PivotPanel only shows one header), where a Grid is used inside ScrollViewer instead of the proper PivotPanel:

<!--UNO TODO: Replace with PivotPanel, when header bug is fixed https://github.com/unoplatform/uno/issues/3596-->
<Grid x:Name="Panel" VerticalAlignment="Stretch">

Related Issues

Activity

  1. added theissue type on Nov 2, 2025
  2. added
    triage/untriaged
    difficulty/tbd
    on Nov 2, 2025
  3. removed
    triage/untriaged
    difficulty/tbd
    on Nov 25, 2025
  4. added
    project/layout 🧱
    area/pivot
    on Nov 25, 2025
  5. github-actions commented on May 17, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  6. added
    stale
    on May 17, 2026
  7. removed
    stale
    on May 18, 2026
  8. github-actions commented on Sep 16, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  9. added
    stale
    on Sep 16, 2026
  10. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    This issue was closed because it had no activity for 10 days after being marked as stale. If you believe this is still relevant, feel free to reopen it or open a new issue with updated context.

  11. MartinZikmund commented on Oct 9, 2026

    @MartinZikmund
    Member

    Reopening - this still reproduces on current master (Uno.Sdk 7.0 dev, Skia desktop), it was only closed by the stale bot.

    Root cause: Uno's Pivot template wraps the items in ScrollViewer x:Name="ScrollViewer" (HorizontalScrollBarVisibility="Hidden"), so everything inside it is measured with infinite width, and its direct child is a plain <Grid x:Name="Panel">. WinUI uses <PivotPanel x:Name="Panel"> there (controls/dev/CommonStyles/Pivot_themeresources.xaml), and PivotPanel::MeasureOverrideImpl (dxaml/phone/lib/PivotPanel_Partial.cpp) measures PivotLayoutElement with the Pivot's section width (set from Pivot::MeasureOverride through PivotStateMachine::MeasureEvent -> SetSectionWidth), "to lay out the PivotItems with a fixed size, even though we're in a ScrollViewer that will measure with infinite extents".

    Without that, a TextBlock/RichTextBlock/TextBox with TextWrapping="Wrap" inside a PivotItem (directly, or inside ScrollViewer > StackPanel) gets an infinite measure width, reports its unwrapped width as DesiredSize and is clipped. Example: in an 860-wide window the text's DesiredSize.Width is 860 (the single line) regardless of the Pivot's width.

    Minimal repro:

    <Pivot Width="300">
        <PivotItem Header="One">
            <ScrollViewer>
                <StackPanel>
                    <TextBlock TextWrapping="Wrap" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." />
                </StackPanel>
            </ScrollViewer>
        </PivotItem>
    </Pivot>

    Expected (WinUI): the text wraps to the Pivot's width. Actual (Uno Skia): one long line, clipped.

    Working on a fix that ports PivotPanel's measure/arrange and uses it in the template, as WinUI does (also relevant to #3596).

  12. self-assigned this
    on Oct 9, 2026
  13. added a commit that references this issue on Oct 10, 2026
    707bc6b
  14. removed
    stale
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/pivotproject/layout 🧱

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions