gpt4 book ai didi

c# - WPF 在元素标记内的 XAML 中使用字符串资源

转载 作者:行者123 更新时间:2023-11-30 15:56:01 24 4
gpt4 key购买 nike

我正在致力于创建支持多语言的 WPF 应用程序。因此,我将所有“可翻译”字符串放入字符串资源中。

我知道如何使用 XAML 中的这些资源,但我在打开和关闭标记中使用它时遇到问题。

例如:

<TextBlock FontSize="16" Padding="2, 5, 0, 0">
<Hyperlink NavigateUri="www.blabla.com/forgotpassword" RequestNavigate="Hyperlink_RequestNavigate">Click here</Hyperlink>
to reset your password!
</TextBlock>

如您所见,Click hereto reset your password! 都在 element 标签内。我的问题是,如何从字符串资源中检索 Click hereto reset your password!

这是我的字符串资源。

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XRManager.Resources"
xmlns:system="clr-namespace:System;assembly=mscorlib">

<system:String x:Key="Click_Here">Click here</system:String>
<system:String x:Key="Click_Here_Part_Reset_Password">to reset your password!</system:String>

</ResourceDictionary>

感谢您的帮助...

最佳答案

也许我看得太简单了,但是像这样就足够了吗?

<TextBlock FontSize="16" Padding="2, 5, 0, 0">
<Hyperlink NavigateUri="www.blabla.com/forgotpassword" RequestNavigate="Hyperlink_RequestNavigate">
<TextBlock Text="{StaticResource Click_Here}"/>
</Hyperlink>
<TextBlock Text="{StaticResource Click_Here_Part_Reset_Password}"/>
</TextBlock>

关于c# - WPF 在元素标记内的 XAML 中使用字符串资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47591945/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com