Reputation: 848
In windows phone 8.1, I can bind the text in a textbox to a string resource in my Resources.resw.
How do I do the same thing for the Header="My Header" tag?
i.e. bind the Header text to another string resource in Resources.resw
<TextBox Header="My Header" Text="{Binding textboxtext}" x:Name="TextBox"/>
Upvotes: 3
Views: 1016
Reputation: 8161
Same way you Bind the Text field.
<TextBox Header="{Binding myBinding}" Text="{Binding textboxtext}" x:Name="TextBox"/>
If you want to point it to a Resource then
<Page.Resources>
<x:String x:Key="myTextBoxHeader">this is a textbox header</x:String>
</Page.Resources>
<TextBox Text="{Binding textboxtest}"
Header="{StaticResource myTextBoxHeader}"></TextBox>
If you pointing to a .resw file then in most cases you will need a x:Uid
like this
<TextBox x:Uid="MyLocalizeTextBox"></TextBox>
Then you need to edit the strings for the stuff you want to display, in this case your Header + Text
Look at the highlighted section very carefully, you see the pattern? It won't show up on the designer and will show up when you deploy [See Image Below]
So by now you may be wondering if you combine both methods? (one to show in the designer and one to show while deploy because you're localizing). This is actually the prefer method.
2 in 1 (Both methods)
<TextBox x:Uid="MyLocalizeTextBox"
Text="{Binding textboxtest}" Header="{StaticResource myBinding}"></TextBox>
During design time it will use your local resouces, when deploy it will use the resources in the resw file.
Upvotes: 2