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 资源部分中分配
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
