I have a XBAP application with the following user control:
<UserControl x:Class="XXX.UsersGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="Auto" Width="Auto">
<UserControl.Resources>
<DataTemplate x:Key="UpArrowUsers">
<DockPanel>
<TextBlock Text="xxUser" x:Name="upArrowUsersHeader" HorizontalAlignment="Center"></TextBlock>
<Path x:Name="arrow" StrokeThickness = "1" Fill= "gray" Data= "M 5,10 L 15,10 L 10,5 L 5,10"/>
</DockPanel>
</DataTemplate>
</UserControl>
...
Now I want to fetch the string "xxUser" from a resx file which is embed as resource in the application How do I achieve this?
Create a static class that makes the resources available as properties:
public static class Resources
{
public string Resource
{
return Properties.Resources.ResourceManager.GetString("Resource");
}
}
Then you can bind your TextBox to this:
<TextBlock Text="{Binding Source={x:Static local:Resources}, Path=Resource}" x:Name="upArrowUsersHeader" HorizontalAlignment="Center"
xmlns:local="clr-namespace:MY_NAMESPACE;assembly=MY_ASSEMBLY">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With