Click here to Skip to main content
15,793,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to change the language of the DocumentViewer from default English to German but with no success.

Being new to WPF, I really struggle to do this.

IMPORTANT: DocumentViewer is created in code behind, in response to the menu item click, and then it is added as main window's Content.

I have tried doing the following, but it seems to do nothing:
myDocumentViewer.Language = System.Windows.Markup.XmlLanguage.GetLanguage("de-DE");

No changes are made, DocumentViewer keeps English.

Googling for proper usage of the Language property, I found nothing useful.


How can I set the language of the DocumentViewer (created with code) to German?
Maciej Los 14-Nov-15 2:22am    
Maciej Los 14-Nov-15 2:31am    
What about: myDocumentViewer.Language = "<object xml:lang='de-DE'/>"
xml:lang Handling in XAML
AlwaysLearningNewStuff 14-Nov-15 5:15am    
Thank you for trying to help, I highly appreciate it.

I am creating document viewer in code, while your suggestion seems to refer to document viewer created in XAML.

Still, I have created document viewer in XAML and tried to set the language as explained in the links you provided. No progress, it still kept English.

I have copy/pasted your suggestion (myDocumentViewer.Language = "<object xml:lang='de-DE'/>") in my code behind, but it did not compile.

again, thank you for trying to help.
Sergey Alexandrovich Kryukov 14-Nov-15 6:16am    
I'm just curious, what do you want to achieve with that property. What "setting language to German" is supposed to do?
So far, you were just trying to read, not set anything...
AlwaysLearningNewStuff 14-Nov-15 7:50am    
What "setting language to German" is supposed to do?

I am trying to set the language of the DocumentViewer to German, so its toolbar and searchbox can display text in their tooltips on German.

I'm just curious, what do you want to achieve with that property.

I am new to WPF, so after doing some research I found that property.

It should change the language of the control, at least that is how I understood it from reading the official documentation.

So far, you were just trying to read, not set anything...

I apologize for my ignorance, but as I have said earlier, I am very new to WPF.

1 solution

I commented the question and asked:
I'm afraid to ask, but don't you expect that changing of the language tag will somehow miraculously cause automatic translation of English tooltips into German?
AlwaysLearningNewStuff finally replied:

Yes! Isn't that what documentation for xml:lang and Language states?

If you set it to "de-DE" then Language changes from default English to German, then tooltips should change from English to German, right?
Of course not. It's not just "not", it's "of course not".

Please read my last comment where I talked about "gravitation demons". If you think that there are some demons inside a computer who translate any arbitrary text, tooltip or not, into one of the languages listed in the standard set of culture info, don't hold your breath. This thinking is in general counter productive and has nothing to do with your knowledge of WPF you are trying to refer to. Better look at any automatic translation tool. I'm less sure about translations between such close languages as English and German, but translation between some other languages is the infinite source of jokes. At the modern level of linguistic science and technology, this can only be a good translation assistant, never a translator…

Sorry for the inconvenience. :-)

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900