Open ghost1372 opened 1 year ago
Just to be sure, have you tried adding the WS_EX_LAYOUTRTL EX style to the window, or have you called SetProcessDefaultLayout with LAYOUT_RTL? Desktop applications are interesting in that they prefer LTR layouts even if the system language is set to one of the RTL languages. Raymond Chen did a blog post about this last year.
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?
First and foremost, welcome to the desktop environment. It has a lot of legacy behaviour that, at this point in time, is difficult to change. Also, when you write "compared to UWP, many features do not work properly", are you sure? Remember, Windows 8 introduced the process model and application type that UWP was based on. This means that the if the default behaviour was changed for the new process model, then "properly" is a relative term. The default LTR window layout, as an example, is the "proper" behaviour in the desktop environment. It is documented in Window Features. "By default, the window layout is left-to-right (LTR)." For using P/Invoke to change the layout, I honestly don't know if this is needed. I am a C++ programmer, so this is what I know and was the quickest method to test things. If you are able to find a .NET provided way of mirroring the window layout then use that instead. For why the desktop environment doesn't support changing the default window mirroring based on setting the process/thread UI languages. This is difficult, but it is definitely behaviour that stems all the way back to Windows 2000 when the multilingual user interface was first introduced. However, the ability to set preferred languages came with Windows Vista. It is possible that this original limitation was due to technical limitations in Windows 2000, it could be that it was just a behaviour decision at that time. The only thing that you can know for sure is that after 23 years, it is unlikely to change now.
The biggest thing you did manage to verify is that WinUI 3 doesn't automatically apply the RTL layout to the underlying desktop window.
ITNOA
But I think WinUI can handle RLT/LTR change layout upper underlying Windows mechanism. and I think WinUI must have all good features and good behavior from UWP. because WinUI (if I understand correctly) wants to replace UWP framework.
@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.
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
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