DocumentViewer "PART_FindToolBarHost" - change default language

Luka Ciglar 21 Reputation points
2020-04-08T17:13:09.45+00:00

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 Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,678 questions
0 comments No comments
{count} votes

Accepted answer
  1. gekka 6,686 Reputation points MVP
    2020-04-09T03:49:17.533+00:00

    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;
            }
        }
    }
    

0 additional answers

Sort by: Most helpful