Topic Author
Posts: 2
Joined: 16 Mar 2018, 03:31

xaml textbox control

06 Jul 2020, 07:58

I want to input some other language text info in Textbox Control,such as Chinese,Japanese..... Now the it just show rect symbol. how should I implement this function?
in addtion. I want to convert the textbox contextmenu "Paste" "Copy" to other language display.
User avatar
Site Admin
Posts: 3064
Joined: 22 Dec 2011, 19:20

Re: xaml textbox control

06 Jul 2020, 18:37

When you see those rects in the text is because the font used doesn't include the corresponding glyphs. You can set <TextBox FontFamily="Microsoft YaHei"> for example to use a font that includes Chinese scripts.

Anyway, I just verified our C# Application Framework is not providing an appropriate set of font fallbacks to avoid this situations, we should fix that for a future release.

In the meantime you can override it in your App.cs:
    partial class App : Application
        protected override string[] GetFontFallbacks()
            return new string[]
                "Theme/Fonts/#PT Root UI",
                "Segoe UI Emoji",           // Windows 10 Emojis
                "Arial Unicode MS",         // Almost everything (but part of MS Office, not Windows)
                "Microsoft Sans Serif",     // Unicode scripts excluding Asian scripts
                "Microsoft YaHei",          // Chinese
                "Gulim",                    // Korean
                "MS Gothic"                 // Japanese

        protected override Display CreateDisplay()
            return new Win32Display();

        protected override RenderContext CreateRenderContext()
            return new RenderContextD3D11();

        static void Main()
            App app = new App();
            app.Uri = "App.xaml";
I want to convert the textbox contextmenu "Paste" "Copy" to other language display.
You can set the ContextMenu property to whatever you want:
      <MenuItem Header="Cut" Command="ApplicationCommands.Cut"/>
      <MenuItem Header="Copy" Command="ApplicationCommands.Copy"/>
      <MenuItem Header="Paste" Command="ApplicationCommands.Paste"/>
This can be set locally in a particular TextBox, or using a <Setter> in a TextBox Style, so it can be shared in multiple text boxes. You can also use bindings in the Header of each menu item so they can change depending on the language of the application.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests