0

I'm implementing WPF XamDataGrid over MVVM architecture. Wondering how can we set the tooltip text of the cells by binding to properties in the View Model file? Any suggestions will be welcome! Anshuman

Anshuman
  • 577
  • 1
  • 8
  • 23

1 Answers1

3

For example you want one tooltip for row and row represent class GridRow.

In GridRow add next:

class GridRow
{
  GridRow() //or other constructor
  {
    ...
    RowToolTip = "Tooltip for one row";
  }

  public string RowToolTip {get; set;}
}

If you want update tooltip in runtime, do not forget implement and use INotifyPropertyChanged for GridRow.

In xaml with your grid add next code:

<igDP:XamDataGrid.Resources>
  <Style TargetType="{x:Type igDP:CellValuePresenter}">
    <Setter Property="ToolTip" Value="{Binding DataItem.RowToolTip}" />
  </Style>
</igDP:XamDataGrid.Resources>

If you need different tooltips for different cells in row, then this need little more code.

sepulka
  • 405
  • 4
  • 15