I am trying to Merge some cells in a WPF datagrid when the values are the same.

But I also have a function for the double clicking the datagrid, where it takes multiple column values from the current row.

At the moment the dg.datacontext = dt.defaultview.
And I manually remove the identical cells in the dt.
if i continue with this approach I will have to look at the cell above, if the current cell is null. Also What would be the way to do this?

Im certain there is an easier way using merging, where the value is kept in all the cells.