Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.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# 用于显示工具提示的DataGridCell模板_C#_Wpf_Tooltip_Contentpresenter_Datagridcell - Fatal编程技术网

C# 用于显示工具提示的DataGridCell模板

C# 用于显示工具提示的DataGridCell模板,c#,wpf,tooltip,contentpresenter,datagridcell,C#,Wpf,Tooltip,Contentpresenter,Datagridcell,我想在DataGridCell上显示工具提示。到目前为止,我尝试了以下方法。但问题是当我停留在DataGridCell上时,整个DataGridCell内容都消失了 <Style TargetType="DataGridCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate Tar

我想在DataGridCell上显示工具提示。到目前为止,我尝试了以下方法。但问题是当我停留在DataGridCell上时,整个DataGridCell内容都消失了

<Style TargetType="DataGridCell">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type DataGridCell}">
                        <ContentPresenter>
                            <ContentPresenter.ToolTip>
                                <ToolTip Content="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget.Content, Mode=OneWay}">
                                </ToolTip>
                            </ContentPresenter.ToolTip>
                        </ContentPresenter>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
</Style>
有人能帮我吗


提前谢谢。

我只使用这种样式。不需要模板

<Style TargetType="DataGridCell">
    <Setter Property="ToolTip">
        <Setter.Value>
            <ToolTip Content="{Binding Path=Day}"/>
        </Setter.Value>
    </Setter>
</Style>

我试过这种方法,找到了解决办法

<Style TargetType="DataGridCell">
    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=Content.Text}"/>
 </Style>

我知道这样可以实现它,但我不想绑定它的DataContext属性。我希望此模板也能与所有其他DataGridCell一起使用。谢谢你的努力。