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

How to bind string of class to resource dictionary

我在文件 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="................" 上绑定 class Enviroment.CurrentDictionary 的字符串?

我尝试为 Hints.xaml 创建代码隐藏并通过 DataContext 进行绑定,但没有成功。

试试这个:

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