0

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>

誰でも私を助けることができます..

前もって感謝します。

4

2 に答える 2

0

これにはスタイルのみを使用します。テンプレートは必要ありません。

<Style TargetType="DataGridCell">
    <Setter Property="ToolTip">
        <Setter.Value>
            <ToolTip Content="{Binding Path=Day}"/>
        </Setter.Value>
    </Setter>
</Style>
于 2014-12-11T10:52:55.647 に答える
0

私はこの方法を試し、解決策を見つけました。

<Style TargetType="DataGridCell">
    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=Content.Text}"/>
 </Style>
于 2014-12-11T12:25:18.817 に答える