question

LukaCiglar-4298 avatar image
0 Votes"
LukaCiglar-4298 asked ·

DocumentViewer "PART_FindToolBarHost" - change default language

Hi,

I would like to use DocumentViewer for print preview of my XPS files. However, the ContentPresenter control known as PART_FindToolBarHost embedded inside DocumentViewer doesn't recognize my Windows language settings, so by default It's everything in English - Textbox watermark, menu names, tooltips etc.

I want It to be in my language (Slovenian) or be able to edit template via VS Blend to fix everything - which unfortunally I couldn't do It.

Here is a screenshot of this control in DocumentViewer:
7194-brez-naslova.png


Is there ANY way I could achieve this ?

Regards, Luka


windows-wpf
brez-naslova.png (1.6 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

gekka avatar image
0 Votes"
gekka answered ·

Hi LukaCiglar,

The string is hard coded in %windir%\Microsoft.NET\Framework\v4.0.30319\WPF\(language)\PresentationUI.resources.dll.
If there are no Slovenian resources, it will be in English.

 private void DocumentViewer_Loaded(object sender, RoutedEventArgs e)
 {
     var dv = (DocumentViewer)sender;
     var host = dv.Template.FindName("PART_FindToolBarHost", dv) as ContentControl;
     var content = host?.Content as Control;
     if (content == null)
     {
         return;
     }
    
     var label = content.FindName("FindTextLabel") as Label;
     if (label != null)
     {
         label.Content = label.Name;
     }
    
     var textBox = content.FindName("FindTextBox") as TextBox;
     if (textBox != null)
     {
         textBox.ToolTip = textBox.Name;
     }
    
     var prev = content.FindName("FindPreviousButton") as Button;
     if (prev != null)
     {
         prev.ToolTip = prev.Name;
     }
    
     var @next = content.FindName("FindNextButton") as Button;
     if (prev != null)
     {
         @next.ToolTip = next.Name;
     }
    
     var menu = content.FindName("OptionsMenu") as Menu;
     if (menu != null)
     {
         var menuItem = menu.Items[0] as MenuItem;
         menuItem.ToolTip = menuItem.Name;
    
         foreach (MenuItem submenu in menuItem.Items)
         {
             submenu.Header = submenu.Name;
         }
     }
 }


· 4 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi gekka,

now that's a relief, many thanks for this. Just one more thing - what do you mean by Slovenian resources, what should I install ?
Because I have Slovenian language pack for Windows 10. Beside that - Messageboxes are too in English, any way to fix that too ?

0 Votes 0 · ·
gekka avatar image gekka LukaCiglar-4298 ·

Unfortunately, I don't know any language packs for .Net framework that is not in this list.

0 Votes 0 · ·

So what you're saying Is that everything would be fine If I would have correct language pack installed ?

Here is my screenshot from Windows 10 - (Isn't that enough?) :

7196-screenshot.jpg


0 Votes 0 · ·
screenshot.jpg (67.6 KiB)
Show more comments