Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 作为ToolTip-WPF内容加载的框架元素的通用属性_C#_Wpf_Data Binding_Datatemplate - Fatal编程技术网

C# 作为ToolTip-WPF内容加载的框架元素的通用属性

C# 作为ToolTip-WPF内容加载的框架元素的通用属性,c#,wpf,data-binding,datatemplate,C#,Wpf,Data Binding,Datatemplate,我有一个带有FramewrokElement的数据模板。就像下面的片段 <DataTemplate x:Key="template"> <Button/> </DataTemplate> 此模板将分配给工具提示,如下面的代码段所示 工具提示工具提示=新工具提示(); tooltip.Content=template.LoadContent() 创建的工具提示将设置为UIElement,类似于使用ToolTipServi

我有一个带有FramewrokElement的数据模板。就像下面的片段

    <DataTemplate x:Key="template">
        <Button/>
    </DataTemplate>


此模板将分配给工具提示,如下面的代码段所示

工具提示工具提示=新工具提示(); tooltip.Content=template.LoadContent()

创建的工具提示将设置为UIElement,类似于使用ToolTipService的另一个内容控件

UIElement UIElement=新UIElement(); SetToolTip(uiElement,tooltip)

在这里,实际的问题,工具提示将是一些UIElement。可以是按钮、文本块、文本框、内容控件等元素的组合

绑定到datatemplate的数据应该在视图中。可以显示特定UIElement上的值的属性是什么

比如说

若我在DataTemplate中有button,我必须绑定到button的ContentProperty,当鼠标移到uiElement上时,该值将显示在视图中的button上

如果我在DataTemplate中有TextBlock,我必须绑定到TextBlock的TextProperty,当鼠标移到uiElement上时,该值将显示在视图中的TextBlock上

或者请给我一些其他的方法来克服它

    <DataTemplate x:Key="template">
        <TextBlock/>
    </DataTemplate>