We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

no empty tooltips in SfDataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

127275 Nov 7,2016 09:37 PM Nov 14,2016 08:52 PM WPF 10
loading
Tags: SfDataGrid
Harald Betzler
Asked On November 7, 2016 09:37 PM

Hi,

one of my grid columns ("Value") has a tooltip binding to another column ("Comment"), which has some empty cells.

The problem ist, that this results in empty tooltip boxes. How can I avoid empty tooltips?

I've tried to use a ToolTipTemplateSelector, with initialization in AutoGeneratingColumn:
if (e.Column.MappingName == "Value")
{
    e.Column.ToolTipTemplateSelector = new ToolTipTemplateSelector();
    e.Column.ShowToolTip = true;
}

public class ToolTipTemplateSelector : DataTemplateSelector
{
    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
        if (item == null || container == null)
            return base.SelectTemplate(item, container);
 
        FrameworkElementFactory factory = new FrameworkElementFactory(typeof(TextBlock));
        factory.SetBinding(TextBlock.TextProperty, new Binding("Comment") { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
        return new DataTemplate { VisualTree = factory };
    }
}
Thanks for your help.

Regards

Harald





Harald Betzler
Replied On November 7, 2016 09:42 PM

Please find attached sample solution.

Attachment: SfGridSample2_e05b57f5.zip

Srinivasan Vasu [Syncfusion]
Replied On November 8, 2016 01:07 AM

Hi Harald, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your provided sample and we have modified your sample based on your requirement. You can avoid the opening of an empty Tooltip by handling the loaded event of the custom TextBlock control. 
  
Please find the modified sample. 
 
 
 
 
 
Regards,
Srinivasan 


Harald Betzler
Replied On November 8, 2016 07:52 AM

Hi Srinivasan,

this works perfect. Thank you.

Regards

Harald

Srinivasan Vasu [Syncfusion]
Replied On November 8, 2016 01:35 PM

Hi Harald, 
  
Thanks for your update. 
  
Please let us know if you need further assistance. 
  
Regards, 
Srinivasan 


Harald Betzler
Replied On November 8, 2016 02:17 PM

Hi Srinivasan,

because there are some cells with tooltips and many cells without tooltips, I want to add a notification symbol in each cell (with a tooltip respectively with a comment). This is necessary because the comment column will be hidden in the future.

The symbol could be a small red dot (or square) in the upper left corner of the cell. Or an "i" like "information".

Do you have a solution? 
(But remember, that I need the complete implementation in code behind.)

Regards

Harald

Srinivasan Vasu [Syncfusion]
Replied On November 9, 2016 08:15 AM

Hi Harald, 

We have checked your query and we have prepared a sample as per your requirement. In this sample, we have modified the GridCell style and add a notification in left corner of the particular cell using converter. 
 
Please download the sample from the below location. 


Regards, 
Srinivasan 
 
 


Harald Betzler
Replied On November 11, 2016 05:34 AM

Hi Srinivasan,

thanks for the sample. It works.

But is it really necessary to provide the complete GridCellStyle (more than 120 lines of xaml code) - only for adding a Border control (with 10 lines)?

Is there no possibility to only add the border to the current CellStyle? Ideally in code behind?

Regards

Harald

Srinivasan Vasu [Syncfusion]
Replied On November 14, 2016 03:57 AM

Hi Harald, 
 
We have checked your query and we have modified the sample based on your requirement. In this sample, we have load the Border control inside the DataTemplate instead of modifying the GridCell Style and change the visibility of UIElement(Border) inside the GridTemplateColumn based on the row data. 
 
Please refer the below Code Example.  
 
C# 
 
if (e.Column.MappingName == "Value") 
            {                
                e.Column.ToolTipTemplateSelector = new ToolTipTemplateSelector();                 
                e.Column.ShowToolTip = true; 
                DataTemplate style = Application.Current.FindResource("GridCellStyle1") as DataTemplate;                 
                e.Column.CellTemplate = style; 
                 
            } 
 
 
XAML 
 
  <DataTemplate x:Key="GridCellStyle1"> 
            <StackPanel> 
                <Border 
                                Width="10" 
                                Height="10" 
                                HorizontalAlignment="Left" 
                                VerticalAlignment="Top" 
                                SnapsToDevicePixels="True"                 
                                Visibility="{Binding Converter={StaticResource visibiltiyconverter}}"> 
                    <Path Data="F1 M 0.500,5.574 L 0.500,9.324 L 4.333,12.823 L 6.000,12.823 L 13.583,4.907 L 13.583,1.241 L 6.000,9.116 L 4.292,9.157 L 0.500,5.574 Z" 
                                  Fill="Green" 
                                  SnapsToDevicePixels="True" 
                                  Stretch="Fill" /> 
                </Border> 
                <TextBlock HorizontalAlignment="Center" Text="{Binding Path=Value}"> 
                </TextBlock> 
            </StackPanel> 
        </DataTemplate> 
 
 
Regards, 
Srinivasan 
 


Harald Betzler
Replied On November 14, 2016 04:08 PM

Hi Srinivasan,

thank you. It works perfectly.

Regards

Harald

Srinivasan Vasu [Syncfusion]
Replied On November 14, 2016 08:52 PM

Hi Harald, 
  
Thanks for your update. 
  
Please let us know if you need further assistance. 
  
Regards, 
Srinivasan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;