Search code examples
wpfresourcedictionary

How to bind string of class to resource dictionary


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>

How i can bind string of class Enviroment.CurrentDictionary on my Text="................" ?

I tried to create code behind for Hints.xaml and bind by DataContext but didnt work .


Solution

  • Try this:

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