Home Forums WPF controls Xceed DataGrid for WPF Add ToolTip when ho vering over Cell

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23523 |

    I’m new to this grid control and to WPF.

    I want to be able to display a tooltip when the mouse of over a cell. The text i want to display is a property of the object that is bound to the grid.

    Any samples would be appreciated. Is there an event I can plug into…?

    Thanks in advance

    Imported from legacy forums. Posted by Greg (had 3691 views)

    Xceed Support
    Member
    Post count: 5658

    <code>
    <Grid xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;
    <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”cvs_orders”
    Source=”{Binding Source={x:Static Application.Current},
    Path=Orders}”/>
    <Style TargetType=”{x:Type xcdg:DataCell}”>
    <Setter Property=”ToolTip”
    Value=”{Binding RelativeSource={RelativeSource Self}, Path=Content}”/>
    </Style>
    </Grid.Resources>
    <xcdg:DataGridControl x:Name=”OrdersGrid”
    ItemsSource=”{Binding Source={StaticResource cvs_orders}}”/>
    </Grid>
    </code>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 597 views)

    User (Old forums)
    Member
    Post count: 23064

    1. EventManager.RegisterClassHandler(typeof(Cell), Cell.MouseEnterEvent, new RoutedEventHandler(OnCellMouseEnter));
    2. private void OnCellMouseEnter(object sender, RoutedEventArgs e)
    {
    Cell cell = (Cell)sender;
    if (cell == null) return;

    double fitWidth = cell.GetFittedWidth();

    if (cell is ColumnManagerCell)//is column
    {
    ColumnManagerCell column = (ColumnManagerCell)cell ;
    if (cell.Width < fitWidth)
    {
    column.ToolTip = column.Content.ToString() ;
    }
    else
    {
    column.ToolTip = null;
    }
    }
    else if(cell is DataCell)// is data
    {
    EntityBase2 enity = cell.DataContext as EntityBase2;
    if (enity!=null && cell.Width < fitWidth)
    {
    cell.ToolTip = enity.Fields[cell.FieldName].CurrentValue.ToString();
    }
    else
    {
    cell.ToolTip = null;
    }

    }
    // e.Handled = true;

    }

    Imported from legacy forums. Posted by PP (had 4020 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi there

    What is EntityBase2 and how to use it?

    Thanks

    Imported from legacy forums. Posted by DarkKnight72 (had 1092 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.