Click here to Skip to main content
15,914,780 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm adding a ToolTip to my DataGrid so that some extra information is displayed when the user hovers over a certain column. I need to be able to style the ToolTip.

What I have tried:

I add a ToolTip to a column like so (for some reason I can't get the code to display right on this website);

<DataGridTextColumn Header="Summary" Binding="{Binding Notes}" Width="*">
<datagridtextcolumn.cellstyle>

&lt;Setter Property="ToolTip" Value="{Binding Notes}"/>




The issue with this solution is that the font is far too small and is difficult to read. Is there a way I can add a custom ToolTip to the column that will allow me to change its font size?
Posted
Updated 12-Dec-16 12:11pm
v5

1 solution

Try something like this:
XML
<DataGridTextColumn Header='Name'
                    Binding='{Binding Path=Name}'  >
    <DataGridTextColumn.CellStyle>
        <Style TargetType="DataGridCell">
            <Setter Property="ToolTip">
                <Setter.Value>
                    <TextBlock FontSize='20'
                               Text='{Binding Name}' />
                </Setter.Value>
            </Setter>

        </Style>
    </DataGridTextColumn.CellStyle>
</DataGridTextColumn>


You can also show additional window when selection is changed :
XML
<DataGrid.RowDetailsTemplate>
    <DataTemplate>
        <Border Margin="10"
                Padding="10"
                BorderBrush="SteelBlue"
                BorderThickness="3"
                CornerRadius="5">
            <TextBlock Text="{Binding Path=Name}"
                       TextWrapping="Wrap"
                       FontSize="10">
            </TextBlock>
        </Border>
    </DataTemplate>
</DataGrid.RowDetailsTemplate>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900