25

I have a Windows 8 Metro application created from the Grid Application template. I need to localize the buttons in the AppBar. Normaly I use x:Uid and .resw for localization but this does not work for the navigation buttons in AppBar.

For example, for the Home button I need to localize the "Home" text. The "Home" text is defined in StandardStyles.xaml as follows:

<Setter Property="AutomationProperties.Name" Value="Home"/>

I tried defining HomeButton.AutomationProperties.Name in resw but I get

Unable to resolve property 'AutomationProperties.Name' while processing properties for Uid

Can anyone help?

Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
Igor Kulman
  • 16,211
  • 10
  • 57
  • 118

1 Answers1

38

take a look at http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965329.aspx where it shows how to use the right RESW syntax for an attached property like this. So if you are using the button styles you could do something like this:

<Button Style="{StaticResource HomeAppBarButtonStyle}" x:Uid="HomeButton" />

And then in your RESW you'd have:

HomeButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name

as your key value.

Hope this helps!

vfportero
  • 918
  • 1
  • 13
  • 26
Tim Heuer
  • 4,301
  • 21
  • 20
  • 1
    It might be worth noting that currently this functionality only works if your resources file has the default Resources.resw filename. – jheriko May 20 '12 at 11:56
  • I tried adding the uid to my button style and this didn't work, so it looks like you can't have localised properties in a style. – Richard Garside May 22 '12 at 20:31
  • 2
    Looks like that article has been removed. Is there a replacement? Is this still the recommended way to go? – Josh Santangelo Aug 01 '12 at 22:19