Tooltip In DataGrid In WPF


I was just having hands on DataGrid in WPF, I was thinking how we can utilize Tooltip in DataGrid. In this article we will see some good implementation here.

Crating WPF Application Project

Fire up Visual Studio 2008 and Create a WPF Application and name the project as TooltipInDataGrid.

We would have a DataGrid in our application. Let’s have some sample data and display it in the DataGrid.

The above class displays the structure of Employee. Now have a list of sample data and display it.

Now we will Customize the DataGrid to have AutoGeneratedColumns = False and we would have our own set of Columns.

As you see in above XAML display, we have first Column as TemplateColumn and rest of the Columns are TextColumns.

Now if we would run the application then we would get the following result.

Perfect. Now we will see how can we use ToolTip to display the cell content.

To display a Tooltip we need to have a TemplateColumn.

As in the previous XAML display we have seen that we have first column as Template Column. Now add the following code so that, we will have a sample ToolTip.

Now we will try to put it all together like all the information on the Tooltip.

Now we will have a good theme that would give a pleasant preview of the Row.

It’s time to use Expression Blend now.

Let’s have the following design.

The following is the Xaml for the above display.

Now that we have the XAML just add this to our TextBlock.ToolTip tag and we will have to bind the Properties.

Always change the following properties of ToolTip such that, our design is transparent to the Background.

That’s it. We are done with this sample, give a try for a better design.

Hope this article helps.

Related Posts:

1) Making Timeline Control for DataGrid In WPF

2) Custom Gridline Color of Datagrid In WPF

3) Custom Row and Header Height of Datagrid In WPF

4) Rounded Corner Datagrid In WPF

5) Grouping In Datagrid In WPF

6) Cell Alignment In DataGrid In WPF

7) Edit Row Details In Context Menu In DataGrid In WPF

8) Hide/Un-Hide Columns Using Context Menu In DataGrid In WPF

9) Hide &Un-Hide DataGrid Column(s) In WPF

10) ComboBox In DataGrid In WPF

11) DatePicker In DataGrid In WPF

12) CRUD Operation In DataGrid In WPF