【问题标题】:How to bind string of class to resource dictionary如何将类字符串绑定到资源字典
【发布时间】:2018-08-06 14:04:47
【问题描述】:

我在文件 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 绑定但没有工作。

【问题讨论】:

    标签: wpf resourcedictionary


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-02
      • 2011-12-14
      • 2023-04-01
      • 1970-01-01
      • 2016-03-27
      相关资源
      最近更新 更多