Reputation: 193
In My UWP app I am maintaining my resources.resw in the Util class library.I have a button like this.
<Button
x:Name="BtnLogin"
x:Uid="LoginButton"
Grid.Row="2"
Margin="0,0,20,20"
HorizontalAlignment="Right"
Click="btn_Login_Click"
Style="{ThemeResource LoginButtonStyle}"
TabIndex="4" />
Button content is set as below in the resources.resw file.
<data name="LoginButton.Content"
xml:space="preserve">
<value>Login</value>
This is the project structure
Place where the UI files maintaining
Place where the resources file maintaining
If the resources file exists in the same project the button content binds properly. When resource file in a different class library the content doesn't bind.
https://learn.microsoft.com/en-us/windows/uwp/app-resources/localize-strings-ui-manifest
Binding from code behind is not a proper answer.I need to bind from the xaml directly like below. https://www.tutorialspoint.com/windows10_development/windows10_development_localization.htm
Upvotes: 0
Views: 47
Reputation: 193
I could fix this using
<Button
x:Name="BtnLogin"
x:Uid="/WinAppUtil/Resources/LoginButton"
Grid.Row="2"
Margin="0,0,20,20"
HorizontalAlignment="Right"
Click="btn_Login_Click"
Style="{ThemeResource LoginButtonStyle}"
TabIndex="4" />
Need to use ClassLibararyName/ResourceFileName/Resource when declaring the x:Uid
Upvotes: 0