How to fetch string from resource to assign in WPF Resource section in xaml(如何从资源中获取字符串以在 xaml 的 WPF 资源部分中分配)
问题描述
我有一个具有以下用户控件的 XBAP 应用程序:
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>
...
现在我想从作为资源嵌入到应用程序中的 resx 文件中获取字符串xxUser"我如何做到这一点?
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?
推荐答案
这些答案都不是你想要的.我将从阅读 WPF 中的本地化开始.您会发现,如果您使用 WPF 进行本地化,您需要在应用程序的每个节点上定义 x:Uid.
None of those answers are close to what you want. I'd start by reading about Localization in WPF. You'll find that if you are doing localization with WPF you'll want x:Uid defined on every node in your app.
http://msdn.microsoft.com/en-us/library/ms788718.aspx
这篇关于如何从资源中获取字符串以在 xaml 的 WPF 资源部分中分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从资源中获取字符串以在 xaml 的 WPF 资源部分中分配


基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01