public class FormatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return Visibility.Collapsed;
FrameworkElement textBlock = (FrameworkElement)value;
textBlock.Measure(new System.Windows.Size(Double.PositiveInfinity, Double.PositiveInfinity));
// Based on Width – Show Tooltip
if (((FrameworkElement)value).ActualWidth < ((FrameworkElement)value).DesiredSize.Width)
return Visibility.Visible;
else
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
} |
<Window.Resources>
<local:FormatConverter x:Key="formatConverter" />
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Visibility" Value="{Binding RelativeSource={RelativeSource Self},
Path=PlacementTarget, Converter={StaticResource formatConverter}}"/>
</Style>
</Window.Resources> |
<Syncfusion:SfDataGrid.Columns>
<Syncfusion:GridTextColumn MappingName="EmployeeName" ShowHeaderToolTip="True"/>
<Syncfusion:GridTextColumn MappingName="EmployeeDesignation" />
<Syncfusion:GridTextColumn MappingName="EmployeeSalary" />
<Syncfusion:GridTextColumn MappingName="EmployeeArea" />
<Syncfusion:GridTextColumn MappingName="EmployeeGender" />
</Syncfusion:SfDataGrid.Columns> |
public class FormatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return Visibility.Collapsed;
if (!(value is GridCell))
return Visibility.Visible;
FrameworkElement textBlock = (FrameworkElement)value;
textBlock.Measure(new System.Windows.Size(Double.PositiveInfinity, Double.PositiveInfinity));
if (((FrameworkElement)value).ActualWidth < ((FrameworkElement)value).DesiredSize.Width)
return Visibility.Visible;
else
return Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
} |
<Syncfusion:SfDataGrid.Resources>
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Visibility" Value="{Binding RelativeSource={RelativeSource Self},
Path=PlacementTarget, Converter={StaticResource formatConverter}}"/>
</Style>
</Syncfusion:SfDataGrid.Resources> |