DataGridImageColumn with ToolTip

Posted by: metabear on 7 August 2017, 5:48 pm EST

  • Posted 7 August 2017, 5:48 pm EST

    Hi,

    how can I add a ToolTip to the DataGridImageColumn in XAML with Databinding?

    I\'m trying next sample, but no luck.







    Thanks
  • Replied 7 August 2017, 5:48 pm EST

    Sorry, here an sample:
    <c1:DataGridImageColumn  Width=\"25\" CanUserSort=\"True\" Binding=\"{Binding Path=aaa, Converter={StaticResource aaa2ImageConverter}}\" >
    <ToolTipService.ToolTip>
    <TextBlock Text=\"{Binding Path=aaa, Converter={StaticResource aaa2ToolTipConverter}}\" />
    </ToolTipService.ToolTip>
    </c1:DataGridImageColumn>

  • Replied 7 August 2017, 5:48 pm EST

    Hello,

    DataGridImageColumn is not a UI element rather it is a logical part of C1DataGrid. Hence, we could not set ToolTip for DataGridImageColumn as you want. As a workaround, I suggest you to use DataGridTemplateColumn wherein, you can define Image control as CellTemplate and set its Tooltip. Here is the suggested markup:

    <c1:C1DataGrid x:Name="c1DataGrid" ItemsSource="{Binding}" AutoGenerateColumns="False">
    <c1:C1DataGrid.Columns>
    <c1:DataGridTemplateColumn Header="C1 Logo">
    <c1:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
    <Image Source="c1.png" Stretch="Fill">
    <ToolTipService.ToolTip>
    <TextBlock Text="{Binding Name}"/>
    </ToolTipService.ToolTip>
    </Image>
    </DataTemplate>
    </c1:DataGridTemplateColumn.CellTemplate>
    </c1:DataGridTemplateColumn>
    <c1:DataGridNumericColumn Header="Employee ID" Binding="{Binding ID}"/>
    <c1:DataGridTextColumn Header="Employee Name" Binding="{Binding Name}"/>
    <c1:DataGridTextColumn Header="Employee Department" Binding="{Binding Department}"/>
    <c1:DataGridTextColumn Header="Employee Location" Binding="{Binding Location}"/>
    </c1:C1DataGrid.Columns>
    </c1:C1DataGrid>

    Please find the attached sample implementing the same and let me know in case of any doubts or queries.

    Regards,
    Prashant
    2016/08/SL_C1DataGrid_ImageColumn.zip
  • Marked as Answer

    Replied 7 August 2017, 5:48 pm EST

    if there are no simple alternative - you can close this thread.

    Thanks!
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels