c# - How to get designtime text visible in a multi-language application in WPF? -


i have wpf application i'm using resource files make multi-language.

like this:

private void application_startup(object sender, startupeventargs e) {     try     {         var lang = new uri("pack://siteoforigin:,,,/languages/" + settings.default.language + ".xaml", urikind.relativeorabsolute);         this.resources.mergeddictionaries.add(new resourcedictionary() { source = lang });     }     catch     {         this.resources.mergeddictionaries.clear();         this.resources.mergeddictionaries.add(new resourcedictionary() { source = new uri("..\\languages\\english.xaml", urikind.relativeorabsolute) });     } } 

so, labels display text, set them this:

<textblock text="{dynamicresource dyouknow}"/> 

this works great @ runtime @ design time don't see default text on labels, makes difficult design/maintain ui.

is there way of doing this?

using markupextension, can create extension can use in xaml provide design-time text well.

you can use follows:

<textblock loc:translateextension.key="txttextkey" text="{loc:translateextension default='default text'}" /> 

see following tutorial: http://www.wpftutorial.net/localizemarkupextension.html


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -