4

I'm translating my UWP app via x: UID property like this.

Code (XAML):

<NavigationViewItem  x:Name="Assistant_Mode" x:Uid="Assistant_Header" Content="Asistan modu" Tag="assistant" ToolTipService.ToolTip="Asistan modu." FontFamily="Segoe UI">

Resource Dictionary record:

Assistant_Header.Content: Asistan modu

Now, I want translate the ToolTipService.ToolTip via Resource dictionary but this keyboard is not work in Dictionary:

Assistant_Header.ToolTipService.ToolTip: Asistan modu

Can I transalte a Tooltip in a Resource Dictionary ? Thanks.

berkb
  • 542
  • 6
  • 21

2 Answers2

10

There's special syntax for referencing attached properties for Uid.

In XAML (as normal):

<Button x:Uid="MyControl"/>

Then in your resw file use key:

MyControl.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip

See docs here.

Michael Hawker - MSFT
  • 1,572
  • 12
  • 18
4

Something you may need to notice is that official recommend way is described in ResourceDictionary and localization:

A XAML ResourceDictionary might initially contain strings that are to be localized. If so, store these strings as project resources instead of in a ResourceDictionary. Take the strings out of the XAML, and instead give the owning element an x:Uid directive value. Then, define a resource in a resources file. Provide a resource name in the form XUIDValue.PropertyName and a resource value of the string that should be localized.

If changing with this way still does not work, what about put the x:uid to the textbox inside ToolTipService.ToolTip, like the following code:

    <Button Content="Button with a simple ToolTip." >
        <ToolTipService.ToolTip>
            <TextBlock x:Uid="test" Text="123456"/>
        </ToolTipService.ToolTip>
    </Button>
Barry Wang
  • 1,459
  • 1
  • 8
  • 12