How to bind string of class to resource dictionary

蹲街弑〆低调 提交于 2019-12-11 07:58:12

问题


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 .


回答1:


Try this:

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


来源:https://stackoverflow.com/questions/51709496/how-to-bind-string-of-class-to-resource-dictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!