如何将类的字符串绑定到资源字典

时间:2018-08-06 14:04:47

标签: wpf resourcedictionary

我有很多工具提示保存在文件hints.xaml中。像这样:

<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的字符串?

我尝试为Hints.xaml创建背后的代码并通过DataContext绑定,但没有成功。

1 个答案:

答案 0 :(得分:1)

尝试一下:

<StackPanel xmlns:system="clr-namespace:System;assembly=mscorlib">
    <Label Content="Nadpis" />
    <TextBlock Text="{x:Static system:Environment.CurrentDirectory}"/>
</StackPanel>
相关问题