3

I am migrating an app from Windows 8 to UWP. The app uses string resources for localization. In Windows 8 I used to do this to localize AppBar buttons:

<Style x:Key="SkipAheadAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
    <Setter Property="AutomationProperties.AutomationId" Value="SkipAheadAppBarButton"/>
    <Setter x:Uid="Step" Property="AutomationProperties.Name" Value=".skip"/>
    <Setter Property="Content" Value="&#xE101;"/>
</Style>

And then I would have a string for "Step.Value". For some reason that does not work in UWP project in Visual Studio 2017. The button shows ".skip" instead of the actual value of Step.Value in Resources.resw.

Simpler <Run x:Uid="App" Text=".Rob"/> works without any problems.

LOST
  • 2,956
  • 3
  • 25
  • 40

1 Answers1

1

We can not use the x:Uid in the Setter.

Use x:Uid to identify an object element in your XAML. Typically this object element is an instance of a control class or other element that is displayed in a UI.

For more info, please refer Remarks of x:Uid directive.

You should be able to add x:Uid in the Button.

For example:

<Button  x:Uid="MyButton" AutomationProperties.Name="AddToIndexButton" Content="Button"></Button>

You should be able to set MyButton.AutomationProperties.Name to the Name and YourValue to the Value of the Resources.resw.

I have also test the <Run x:Uid="App" Text=".Rob"/>, it will throw exception. If you can use it in UWP, could you please give us a sample?

Community
  • 1
  • 1
Jayden
  • 3,276
  • 1
  • 10
  • 14