question

ApptacularApps-8305 avatar image
0 Votes"
ApptacularApps-8305 asked ·

How to use string resource in TextBox

How can a string resource be used for a TextBox?

I understand that I need to use something like:

 <x:String x:Key="Placeholder">Placeholder Content</x:String>

but I don't know how.

 <TextBox 
     x:Name="nameInput"
     PlaceholderText="Find a setting"
     Width="300" 
     HorizontalAlignment="Left"
     Margin="0,0,0,20" />
windows-uwpwindows-uwp-xaml
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello, is the answer below solved your problem? If so, you can accept it, this will help more people who have the same problem, thank you.

0 Votes 0 ·
danielescipioni avatar image
0 Votes"
danielescipioni answered ·

If I understand correctly you want to put that Placeholder in TextBox.PlaceholderText. Then define a resource

<Page.Resources>
    <x:String x:Key="Placeholder">Placeholder Content</x:String>
</Page.Resources>

and use it as StaticResource in the TextBox.PlaceholderText

<TextBox PlaceholderText="{StaticResource Placeholder}"/>

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

mrlacey avatar image
0 Votes"
mrlacey answered ·

You can also define strings in a resource (RESW) file and use Unique Identifiers (Uid) to connect the resource with where it should be used:

9161-placeholdertext-resource.png



·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.