2

本地化 WPF 应用程序需要哪些步骤才能正确显示从右到左的语言?

4

2 回答 2

2

我意识到这是一个老问题,但我也坚持这个问题,所以我添加了我所做的(部分有效),希望有人会添加更多

在你的 app.cs 你可以做这样的事情

    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        FrameworkElement.LanguageProperty.OverrideMetadata(
          typeof(FrameworkElement),
          new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

        FrameworkElement.FlowDirectionProperty.OverrideMetadata(
        typeof(FrameworkElement),
        new FrameworkPropertyMetadata(CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft
                                      ? FlowDirection.RightToLeft : FlowDirection.LeftToRight));

    }

现在这一切都可以翻转,但它也碰巧翻转了所有不是你真正想要的图像。

于 2010-06-18T19:32:44.853 回答
0

对于我的用例,在MainWindow.cs中添加以下代码就足够了:

    public MainWindow()
    {
        InitializeComponent();
        // Here
        this.FlowDirection =
            CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft ?
                FlowDirection.RightToLeft :
                FlowDirection.LeftToRight;
    }
于 2021-10-29T21:18:00.080 回答