本地化功能区按钮中的文本
我有一个带有许多按钮的功能区窗口,它们正在使用这样的资源,
<r:RibbonWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml" />
</ResourceDictionary.MergedDictionaries>
<r:RibbonCommand x:Key="CopyCommand"
LabelTitle="Copy"
ToolTipDescription="Copy something"
Executed="OnIgnore"
LargeImageSource="images/Flag/de-DE.png"
SmallImageSource="images/Flag/en-GB.png"
/>
</ResourceDictionary>
</r:RibbonWindow.Resources>
<DockPanel>
<r:Ribbon DockPanel.Dock="Top" Title="EasyLink">
<r:RibbonTab Label="Home">
<r:RibbonGroup Name="Clipboard" GroupSizeDefinitions="{StaticResource RibbonLayout}">
<r:RibbonButton Name="Copy" Command="{StaticResource CopyCommand}" />
</r:RibbonGroup>
</r:RibbonTab>
<r:RibbonTab Label="Help">
</r:RibbonTab>
</r:Ribbon>
</DockPanel>
我想使用“字符串”概念让按钮根据语言更改文本。
我已尝试以下操作
<r:RibbonCommand x:Key="CopyCommand"
LabelTitle="me:strings.Copy"
,
<r:RibbonCommand x:Key="CopyCommand"
LabelTitle="/Test;strings.Copy"
但它不起作用,我应该在其他地方(也许是在 C# 代码中)执行此操作吗?
I have a ribbon window with a number of buttons wich is using a resources like this
<r:RibbonWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml" />
</ResourceDictionary.MergedDictionaries>
<r:RibbonCommand x:Key="CopyCommand"
LabelTitle="Copy"
ToolTipDescription="Copy something"
Executed="OnIgnore"
LargeImageSource="images/Flag/de-DE.png"
SmallImageSource="images/Flag/en-GB.png"
/>
</ResourceDictionary>
</r:RibbonWindow.Resources>
<DockPanel>
<r:Ribbon DockPanel.Dock="Top" Title="EasyLink">
<r:RibbonTab Label="Home">
<r:RibbonGroup Name="Clipboard" GroupSizeDefinitions="{StaticResource RibbonLayout}">
<r:RibbonButton Name="Copy" Command="{StaticResource CopyCommand}" />
</r:RibbonGroup>
</r:RibbonTab>
<r:RibbonTab Label="Help">
</r:RibbonTab>
</r:Ribbon>
</DockPanel>
I want to use the "strings" concept to have the buttons change text depending on the language.
I have tried the following
<r:RibbonCommand x:Key="CopyCommand"
LabelTitle="me:strings.Copy"
and
<r:RibbonCommand x:Key="CopyCommand"
LabelTitle="/Test;strings.Copy"
but it did not work, should I do it elsewhere, in the C# code perhaps ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现 WPF 中 UI 元素声明式本地化的最佳且最简单的解决方案是 WPF 本地化扩展 (http://wpflocalizeextension.codeplex.com/)。它提供了额外的表达,例如:
额外的好处是,当当前用户无法使用本地化时,它支持回退机制。
我个人将它与 Ribbon 一起使用,非常顺利。
The best and easiest solution to declarative localization of UI elements in WPF that I found is the WPF Localization Extension (http://wpflocalizeextension.codeplex.com/). It provides additional expression, for example:
The additional benefits are that it supports fall-back mechanism when localization is not available for current user.
I personally used it with Ribbon and it went quite smooth.
我在这里找到了答案
http://gargmanoj。 wordpress.com/2009/03/18/accessing-strings-from-resource-file-in-xaml-markup/
需要将字符串资源公开并将它们称为静态
问候
I found the answear here
http://gargmanoj.wordpress.com/2009/03/18/accessing-strings-from-resource-file-in-xaml-markup/
It is needed to make the string resources Public and refer to them as static
Regards