WPF:指定内置命令标签的语言

发布于 2024-09-18 13:18:40 字数 781 浏览 4 评论 0原文

我使用内置的 ApplicationCommands 创建菜单:

<Menu DockPanel.Dock="Top">
    <MenuItem Header="_Datei">
        <MenuItem Command="ApplicationCommands.New" />
        <MenuItem Command="ApplicationCommands.Open" />
        <MenuItem Command="ApplicationCommands.Save" />
        <MenuItem Command="ApplicationCommands.SaveAs" />
        <Separator />
        <MenuItem Header="Been_den" Command="{StaticResource SchliessenCommand}" />
    </MenuItem>
</Menu>

ApplicationCommands 显示的文本因系统语言而异:在英语 Windows 7 上运行,ApplicationCommands.New 显示为“New”,而在德语 Windows 7 上显示为“Neu”。

由于应用程序的其余部分未本地化,我希望应用程序命令始终以德语显示。有没有办法无需手动设置每个菜单项的标题

I'm using the built-in ApplicationCommands to create a menu:

<Menu DockPanel.Dock="Top">
    <MenuItem Header="_Datei">
        <MenuItem Command="ApplicationCommands.New" />
        <MenuItem Command="ApplicationCommands.Open" />
        <MenuItem Command="ApplicationCommands.Save" />
        <MenuItem Command="ApplicationCommands.SaveAs" />
        <Separator />
        <MenuItem Header="Been_den" Command="{StaticResource SchliessenCommand}" />
    </MenuItem>
</Menu>

The text displayed by the ApplicationCommands differs depending on the system language: Running on an English Windows 7, ApplicationCommands.New displays as "New", whereas it displays as "Neu" on a German Windows 7.

Since the rest of the application is not localized, I want the application commands to always display in German language. Is there a way to do that without manually setting the Header of each MenuItem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱已欠费 2024-09-25 13:18:40

由于该应用程序未本地化,您可以尝试始终将语言设置为德语;也就是说,CultureInfo.CurrentUICulture,它通常是从操作系统继承的(在打开任何窗口之前在应用程序启动或类似的操作中设置它)。

Since the application isn't localized, you can try to always set the language to german; that is, CultureInfo.CurrentUICulture, which is normally inherited from the OS (set it in application startup or something like that, before any windows are opened).

回眸一遍 2024-09-25 13:18:40

您应该使用绑定并将命令作为绑定对象进行操作 (RelayCommands) 以避免对不同命令的标头进行硬编码。

You should use bindings and manipulate your commands as bind objects (RelayCommands) to avoid the hardcoding of the headers of your different commands.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文