开发者

WPF: Specify a language for built-in Command labels

I'm using the built-in Appl开发者_如何转开发icationCommands 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?


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).


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜