1

I am trying to set the Window title of a Maui application to be a value containing Unicode (say Japanese) characters. The Japanese characters (and other unicode characters) appear as '?'

I set the title as follows

protected override Window CreateWindow(IActivationState activationState)
{
  Window window = base.CreateWindow(activationState);
  window.Title = "Hello こんにちは World Test";
  return window;
}

In a minimal Maui application ... this has the expected result.

In my much more complex application (with a bit of Windows specific behavior and API calls), the Japanese appears as ????.

My guess is that I am messing up the low-level window somehow.

What might cause this problem ?


Upon more investigation ... it seems that somehow the presence of a a lifecycle event causes the problem. I have a

 builder.UseMauiApp<App>()
            .ConfigureLifecycleEvents(events =>
                {
                events.AddWindows(win => win
                        .OnWindowCreated((window) => {

When I remove the event, the problem goes away. The event implementation itself was just an empty code block.

I cannot replicate this in a 'minimal' application

mlg
  • 101
  • 2
  • 8

1 Answers1

0

I found that the behavior is correct if I set the title this way

IWindow iWindow = Application.Windows[0];
Microsoft.Maui.Controls.Window xxx = iWindow as Microsoft.Maui.Controls.Window;
xxx.Title = "hello there こんにちは ";

If it is set like this

IWindow iWindow = Application.Windows[0];
MauiWinUIWindow www = iWindow.Handler.PlatformView as MauiWinUIWindow;
xxx.Title = "hello there こんにちは ";

Either no title is visible or the unicode is as ??? depending on if ExtendsContentIntoTitleBar is set.

mlg
  • 101
  • 2
  • 8