Skip to content

FontIcon.MirroredWhenRightToLeft is ignored when FlowDirection is inherited or changes later #26675

Backlog

Description

@morning4coffe-dev

Current behavior 🐛

FontIcon.MirroredWhenRightToLeft="True" only mirrors the icon if the effective FlowDirection is already RightToLeft at the moment MirroredWhenRightToLeft itself is set. It is not re-evaluated when FlowDirection changes, so:

  • an icon that gets RightToLeft from a parent (the normal case, for example <Page FlowDirection="RightToLeft">) is not mirrored,
  • an icon whose tree is switched to RightToLeft at runtime is not mirrored.

A FontIcon created from XAML (or inside a control template) gets MirroredWhenRightToLeft set while it is still detached, so its effective FlowDirection is still LeftToRight then.

I checked it with a runtime test, on Uno.Sdk 7.1.0-dev.478, Skia desktop (macOS). RenderTransform is the ScaleTransform that FontIcon adds to mirror itself:

Case Result
A. MirroredWhenRightToLeft=true set, then the icon is added to a parent with FlowDirection=RightToLeft (effective FlowDirection is RightToLeft) no transform, not mirrored
B. FlowDirection=RightToLeft set on the icon first, then MirroredWhenRightToLeft=true ScaleX=-1, mirrored
C. icon in a left-to-right parent, then the parent is changed to RightToLeft no transform, not mirrored
D. icon in a right-to-left parent, then MirroredWhenRightToLeft=true is set ScaleX=-1, mirrored

Expected behavior 🎯

The icon is mirrored whenever its effective FlowDirection is RightToLeft, whatever the order of the changes, like in WinUI. Uno's own Fluent templates rely on this (TabView, PipsPager, AppBarButton and RadioMenuFlyoutItem in Uno.UI.FluentTheme all set MirroredWhenRightToLeft), so I expect the same code path to be affected there, but I only checked the FontIcon itself.

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

<StackPanel FlowDirection="RightToLeft">
    <!-- A: stays pointing left, it should point right -->
    <Button Width="56" Height="40">
        <FontIcon Glyph="&#xE72B;" MirroredWhenRightToLeft="True" FontSize="16" />
    </Button>
    <!-- B: pointing right, because FlowDirection is set on the icon before the property -->
    <Button Width="56" Height="40">
        <FontIcon Glyph="&#xE72B;" FlowDirection="RightToLeft" MirroredWhenRightToLeft="True" FontSize="16" />
    </Button>
</StackPanel>

A, B and an unmirrored reference

(A is the first button, B the second, and the third one is a plain reference without mirroring.)

As a runtime test (a sketch, it was not compiled in the Uno repo; the same assertions ran in a probe in another project, and fail for A and C today):

[TestMethod]
public async Task When_FlowDirection_Is_Inherited_Or_Changes_Icon_Is_Mirrored()
{
    var inherited = new FontIcon { Glyph = "\uE72B", MirroredWhenRightToLeft = true };
    var inheritedHost = new Grid { FlowDirection = FlowDirection.RightToLeft, Children = { inherited } };

    var flipped = new FontIcon { Glyph = "\uE72B", MirroredWhenRightToLeft = true };
    var flippedHost = new Grid { Children = { flipped } };

    WindowHelper.WindowContent = new StackPanel { Children = { inheritedHost, flippedHost } };
    await WindowHelper.WaitForLoaded(inherited);
    flippedHost.FlowDirection = FlowDirection.RightToLeft;
    await WindowHelper.WaitForIdle();

    Assert.AreEqual(-1d, (inherited.RenderTransform as ScaleTransform)?.ScaleX);
    Assert.AreEqual(-1d, (flipped.RenderTransform as ScaleTransform)?.ScaleX);
}

The existing Given_FontIcon tests do not cover mirroring.

Cause, in src/Uno.UI/UI/Xaml/Controls/Icons/FontIcon.cs (the file is identical on master): UpdateMirroring() is only called from the property-changed callback of MirroredWhenRightToLeft, and there is no handler for FlowDirection changes. Calling it also when FlowDirection changes should fix A and C.

Workaround 🛠️

Set FlowDirection="RightToLeft" on the FontIcon itself before MirroredWhenRightToLeft (case B), or set MirroredWhenRightToLeft after the icon is in the right-to-left tree (case D).

Affected platforms 📱💻🖥️

I tested on Desktop (macOS, Skia). FontIcon.cs is shared code, so other platforms are probably affected too.

Uno.Sdk version (and other relevant versions) 📦

Uno.Sdk 7.1.0-dev.478

IDE version 🧑‍💻

Command line (dotnet build), no IDE.

Activity

  1. added
    triage/untriaged
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage/untriaged

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions