question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not make RTL language application in WinUI 3

See original GitHub issue

Describe the bug

i want to make my winui 3 app RTL, this means All layouts, including the TitleBar and Custom TitleBar, should be right to left! It is very strange that this was done easily in the previous versions. But it is not possible in the latest version (1.3.2)

Steps to reproduce the bug

I did the following methods none of them change the language/layout of the app

Method Value TitleBar Content
MainWindow Top Level UIElement.FlowDirection RightToLeft No Change [LTR] Yes RTL
Package.appxmanifest DefaultLanguage = fa-IR or fa No Change [LTR] No Change [LTR]
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride fa-IR or fa No Change [LTR] No Change [LTR]
Thread.CurrentThread fa-IR or fa No Change [LTR] No Change [LTR]
m_resourceContext.QualifierValues[“Language”] fa-IR or fa No Change [LTR] No Change [LTR]
Custom TitleBar (AppWindow) - Grid.FlowDirection RightToLeft No Change [LTR] No Change [LTR]

Expected behavior

At least one of the above methods should change the language of the program, but nothing happens. I also changed the Windows Language settings, but nothing happens

Screenshots

No response

NuGet package version

Windows App SDK 1.3.2: 1.3.230602002

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

### Tasks

Issue Analytics

  • State:open
  • Created 3 months ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghost1372commented, Jul 2, 2023

tnx, using SetProcessDefaultLayout and WS_EX_LAYOUTRTL EX working fine! however Compared to UWP, many features do not work properly. Why do I need to use PInvoke to change the layout, while UWP provides this possibility by changing the language code?

0reactions
DarranRowecommented, Jul 9, 2023

@soroshsabz The thing to remember here is that, just because the current behaviour is to require setting the layout manually. This doesn’t mean that it is intended or desired behaviour in WinUI 3. Microsoft.UI.Xaml.Window can check the current preferred UI languages and then apply the WS_EX_LAYOUTRTL style to the underlying window if it wants to. This is, IMO, the whole root of the problem. The desktop behaviour is unexpected and it is easy to get caught out if you are used to working with CoreWindow. We’ll see how this is resolved when the issue is closed, however, I would expect that the resolution would only apply to WinUI 3 and not have any surprising effects when applied to a desktop application that uses the Windows App SDK.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not make RTL language application in WinUI 3 #8746
i want to make my winui 3 app RTL, this means All layouts, including the TitleBar and Custom TitleBar, should be right to...
Read more >
Adjust layout and fonts, and support RTL - Windows apps
Design your app to support the layouts and fonts of multiple languages, including RTL (right-to-left) flow direction.
Read more >
Enable RTL Mode in a Right-to-Left Culture Application
This topic shows how to enable Right-to-Left mode in an application that uses a single right-to-left (RTL) culture. To learn how to support...
Read more >
Get the display language that my application is currently ...
To achieve that, I would need to know what language my app is currently running with. Initially, if the user hasn't picked a...
Read more >
Right-to-left language (RTL) support in our WPF controls - Blogs
One of the reasons is simple: we're all LTR people at DevExpress, of different languages and countries, sure, but we all read from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found