2016-12-29 32 views
0

私はwpf c#アプリを持っています。データグリッドセルにツールチップを追加するには

私はDataGridコントロールを使用しています。

これらのセルのうちの1つについて、私はマルチラインのツールチップを示したいと思います。

これは私のコードです:

<DataGridTextColumn Header="{x:Static prop:Resources.Address}" Binding="{Binding Address}" > 
    <ToolTipService.ToolTip> 
     <StackPanel> 
      <TextBlock Text="Line#1" /> 
      <TextBlock Text="Line#2" /> 
     </StackPanel> 
    </ToolTipService.ToolTip> 
</DataGridTextColumn> 

しかし、私はこれを実行すると何のツールチップが表示されませんか?

答えて

2

あなたはCellStyleを使用してDataGridCellのToolTipプロパティを設定できます

<DataGridTextColumn Header="{x:Static prop:Resources.Address}" Binding="{Binding Address}" > 
    <DataGridTextColumn.CellStyle> 
     <Style TargetType="DataGridCell"> 
      <Setter Property="ToolTip"> 
       <Setter.Value> 
        <ToolTip> 
         <StackPanel> 
          <TextBlock Text="Line#1" /> 
          <TextBlock Text="Line#2" /> 
         </StackPanel> 
        </ToolTip> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </DataGridTextColumn.CellStyle> 
</DataGridTextColumn> 
+0

感謝を。私はそれを試みたと断言することができた。私は何かを逃してしまったに違いない。どうもありがとう :) –

関連する問題