如何将类字符串绑定到资源字典 [英] How to bind string of class to resource dictionary
本文介绍了如何将类字符串绑定到资源字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在文件 hints.xaml 中保存了许多工具提示.像这样:
I have many tooltips saved in file hints.xaml . Like this :
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp7.Theme"
x:Class="WpfApp7.Theme.Hints">
<ToolTip x:Key="myToolTip" >
<StackPanel >
<Label Content="Nadpis" />
<TextBlock Text="................"/>
</StackPanel>
</ToolTip>
</ResourceDictionary>
如何在我的 Text="................" 上绑定类 Enviroment.CurrentDictionary 的字符串?
How i can bind string of class Enviroment.CurrentDictionary on my Text="................" ?
我尝试为 Hints.xaml 创建代码并通过 DataContext 绑定,但没有成功.
I tried to create code behind for Hints.xaml and bind by DataContext but didnt work .
推荐答案
试试这个:
<StackPanel xmlns:system="clr-namespace:System;assembly=mscorlib">
<Label Content="Nadpis" />
<TextBlock Text="{x:Static system:Environment.CurrentDirectory}"/>
</StackPanel>
这篇关于如何将类字符串绑定到资源字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文