C# 作为ToolTip-WPF内容加载的框架元素的通用属性
我有一个带有FramewrokElement的数据模板。就像下面的片段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
<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>