http://wpflocalizeextension.codeplex.com/
<MvvmCore:RibbonCommandExtended x:Key="SwitchLanguageCommand"
CanExecute="RibbonCommandExtended_CanExecute"
Executed="RibbonCommandExtended_Executed"
LabelTitle="{lex:LocText Key=SwitchLanguage,Dict=LanRes}"
ToolTipTitle="{lex:LocText Key=SwitchLanguage,Dict=LanRes}"
LargeImageSource="{lex:LocImage Key=ChangeLanguage,Dict=LanRes}"/>
<rb:RibbonButton x:Name="EnglishButton" Command="{StaticResource SwitchToEnglishCommand}" Click="EnglishButton_Click">
这是我的RibbonCommand扩展类。
public class RibbonCommandExtended : RibbonCommand
{
private ICommand m_command;
public ICommand Command
{
get { return m_command; }
set
{
m_command = value;
if (m_command != null)
{
this.CanExecute += UsCanExecute;
this.Executed += UsExecuted;
}
else
{
this.CanExecute -= UsCanExecute;
this.Executed -= UsExecuted;
}
}
}
private void UsExecuted(object sender, ExecutedRoutedEventArgs e)
{
Command.Execute(e.Parameter);
}
private void UsCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = Command.CanExecute(e.Parameter);
}
}
当我的程序启动时,ribbon控件会选择正确的语言字符串和图像。但是当我在运行时更改语言时,我在功能区控件本地化的文本和图像中看不到任何更改。因为RibbonCommand的LabelTitle、LargeImageSource和所有其他属性都不是依赖属性。
已经有人解决这个问题了吗?或者除了本地化扩展之外,还有其他方法可以使我的应用程序本地化,从而满足我的需求吗?