How do I bind the title of a TextBox?

On Windows phone 8.1, I can bind the text in a textbox to a string resource in my .resw resource.

How do I do the same for the Header = My Header tag?

i.e. link header text to another string resource in Resource.resw

<TextBox Header="My Header" Text="{Binding textboxtext}" x:Name="TextBox"/>

      

+3


source to share


1 answer


Likewise, you bind the textbox.

<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>

      

enter image description here

If you specify a .resw file then in most cases you will need x:Uid

like this

<TextBox x:Uid="MyLocalizeTextBox"></TextBox>

      

Then you need to edit the lines for the material you want to display, in this case title + text



enter image description here

Look at the highlighted section very carefully, do you see the picture? It will not be displayed on the designer and will be displayed when deployed [See Image Below]

enter image description here


So now you might be wondering if you combine both methods? (one to show in the designer and one to show during deployment because you are localizing). This is indeed the preferred method.

2 in 1 (both methods)

<TextBox x:Uid="MyLocalizeTextBox"
    Text="{Binding textboxtest}" Header="{StaticResource myBinding}"></TextBox>

      

During development it will use your local resources, when deployed it will use resources in the resw file.

+2


source







All Articles