Articles in this section
Category / Section

How to set custom tooltip for OlapGrid

1 min read

We can customize the tooltip text using the GridStyleInfo object which can be obtained from QueryCellInfo event. We have created a custom template with a custom converter named “MyValueCellToolTipConvertor” to set the desired text.

XAML

<ResourceDictionary >
            <localVM:MyValueCellToolTipConvertor x:Key="valueConverter"/>
        </ResourceDictionary>
        <DataTemplate x:Key="ValueTemplateTooltip">
            <Border BorderThickness="1" BorderBrush="Black" Background="Gold" CornerRadius="2">
                <StackPanel Margin="5" Orientation="Horizontal" VerticalAlignment="Center">
                    <TextBlock Text="{Binding Converter={StaticResource valueConverter}, ConverterParameter='MyMeasure'}" VerticalAlignment="Center"/>
                </StackPanel>
            </Border>
        </DataTemplate>

 

C#

 
  public class MyValueCellToolTipConvertor : IValueConverter
    {
 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            GridStyleInfo style = value as GridStyleInfo;
            if (style != null)
            {
                OlapGridCellStyleInfoIdentity olapCellStyle = style.Tag as OlapGridCellStyleInfoIdentity;
                if (olapCellStyle != null && olapCellStyle.CellDescriptor != null && parameter != null)
                {
                    PivotValueCellData pivotValueCellData = (style.CellIdentity.Data.Host as OlapGridModel).Engine.GetCellDataValue(olapCellStyle.RowIndex, olapCellStyle.ColumnIndex);
                    switch (parameter.ToString())
                    {
                        case "MyMeasure":
                            {
                                //olapCellStyle.CellDescriptor.KpiType;
                                Cell cel = olapCellStyle.CellDescriptor.Tag as Cell;
                                return cel.FormattedValue;
                            }
                    }
                }
            }
            return null;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

 

Figure: OlapGrid in OlapClient with Custom Tooltip

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied