i have followed the article: Localization of a WPF application using a custom MarkupExtension for internazionalizing my app.
In my MainWindow.xaml i have:
<Button x:Name="ServiceButton" Content="{l:Translate service.button.start}" Click="toggle_service_click" />
As you can see the translate markup {l:Translate service.button.start} is written to retrieve the string service.button.start in my current locale resource file when app is loaded, but if the service is already started the markup string should be service.button.stop
So, in practice, whene i run my app, if the service is started:
<Button x:Name="ServiceButton" Content="{l:Translate service.button.stop}" Click="toggle_service_click" />
otherwise
<Button x:Name="ServiceButton" Content="{l:Translate service.button.start}" Click="toggle_service_click" />
How i can set the corret markup "On the fly" directly in the xaml file before that translationManager parse it?
EDIT: I have tryed to bind it in my DataContext like this: dataContext
public object ServiceTplString
{
get
{
var isr = ServiceHandler.Instance.serviceIsRunning("service_alias", "service_name");
return "{l:Translate service.button." + ( (isr) ? "stop" : "start" ) + "}";
}
}
MainApplication.xaml:
<Button x:Name="ServiceButton" Content="{Binding ServiceTplString}" Click="toggle_service_click" />
but doesnt work..