locked
Should TextBlock work for Chinese? RRS feed

  • Question

  • I have a SL app that we have localized to get all our strings from a table.  We have TextBlocks with bound strings, but it doesn't show the right characters. A TextBox on the other hand can accept and read Chinese with no problem.

    Anybody know what is up with TextBlock?


    • Edited by mltiede Wednesday, March 9, 2016 6:27 PM
    Wednesday, March 9, 2016 6:26 PM

Answers

  • What happened was, the strings were stored in the database. And the COLUMN that was being used was declared as VARCHAR. So it couldn't HOLD a Chinese string.

    Once I changed it to an NVARCHAR and changed my literals in some Sql to N'xxx', then it all worked as it should.

    Glad of THAT!  :-)

    Thursday, March 10, 2016 10:30 PM

All replies

  • Hi mltiede,

    Yes, TextBlock work for Chinese.

    I create a sample project and bind a Name property (the value is Chinese) of a Class to the Text property of the TextBlock with below code. It works fine when the application running.

    <TextBlock HorizontalAlignment="Left" Margin="10,20,0,0" TextWrapping="Wrap" Text="{Binding Name}" VerticalAlignment="Top"/>

    Please set the Text property value as Chinese string directly in your XAML code to check whether it can show correctly. Then please check all strings in the table whether all of them correctly.

    If possible, please share some code snippet to help us reproduce your problem.

    Best Regards,
    Weiwei

    Thursday, March 10, 2016 5:56 AM
    Moderator
  • Maybe it's the machine/thread culture is the problem.

    Weiwei might have culture set to Chinese.

    Persuading wpf to show Arabic characters properly is pretty fiddly, I can't recall ever trying with Silverlight.

    I would have thought both controls would behave the same though.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Thursday, March 10, 2016 8:01 PM
    Moderator
  • What happened was, the strings were stored in the database. And the COLUMN that was being used was declared as VARCHAR. So it couldn't HOLD a Chinese string.

    Once I changed it to an NVARCHAR and changed my literals in some Sql to N'xxx', then it all worked as it should.

    Glad of THAT!  :-)

    Thursday, March 10, 2016 10:30 PM