Hi,
My application has to support multiple languages and should be able to switch the language on run time. For that purpose I am using LocalizationExtension from codeplex (http://wpflocalizeextension.codeplex.com/) I am using Ribbon Contorl in my application. I am creating ribbonCommands as window resource and Binding the LableTitle and other properties withLocalizationExtension class.
<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}"/>
Then assigning it to button Command property as static resource.
<rb:RibbonButton x:Name="EnglishButton" Command="{StaticResource SwitchToEnglishCommand}" Click="EnglishButton_Click">
Here is my RibbonCommandExtended class.
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);
}
}
When my program starts, then the ribbon control picks the right language strings and images. But when I change the language on runtime then I could't see any change in ribbon control localized text and image. Because the RibbonCommand's LabelTitle, LargeImageSource and all other properties are not Dependency properties.
Have someone solved the issue already? Or is there any other way rather then LocalizationExtension to make my application localized so that it fulfills my requirements?