简体   繁体   中英

How to use same string resource for different item types

I have a String called Products.Label which is use for an AppBarButton . How can I use the same string for a TextBox without the app crashing?

MainPage.xaml

...
<AppBarButton Name="AppBarButtonProducts" x:Uid="Products"/>
...

Settings.xaml

...
<TextBlock x:Uid="Products/Label" Style="{StaticResource HeaderTextBlockStyle}" />
...

How to use same string resource for different item types

You could make x:string resource in the application resource for different control like the following.

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


<TextBox
    Height="44"
    PlaceholderText="dddd"
    Text="{StaticResource Placeholder}"
    />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM