MicroBoxPlot ToolTip

Micro Charts for WPF Forum

Posted 2 months ago by Ralf Lieb
Version: 22.1.5

How to bind to Minimum/Mean/Maximum etc from inside <MicroBoxPlot.ToolTip> ?

I've got a custom tooltip, but I can't figure the the binding path to Minimum/Q1/Q2 etc. 

Comments (4)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA

Hi Ralf,

It looks like the values supplied to LegendStringFormat when coercing our default ToolTip string come from the internal plotter, and not all of those are available outside of the control internals since they aren't published as dependency properties.

What did you have on your custom ToolTip beyond what the default one offers?

Actipro Software Support

Posted 2 months ago by Ralf Lieb

I want to show the exsting statistics in a table and add some additional custom calculation result

Something like:

			<Style TargetType="{x:Type TextBlock}">
					<Trigger Property="Grid.Column" Value="1">
						<Setter Property="Margin" Value="20,0"/>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition Width="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
		<TextBlock Grid.Row="0" Grid.Column="0" Text="Minimum"/>
		<TextBlock Grid.Row="0" Grid.Column="1" Text="0.01"/><!-- need existing minimum -->
		<TextBlock Grid.Row="1" Grid.Column="0" Text="Median"/>
		<TextBlock Grid.Row="1" Grid.Column="1" Text="0.50"/><!-- need existing median -->
		<TextBlock Grid.Row="2" Grid.Column="0" Text="Mean"/>
		<TextBlock Grid.Row="2" Grid.Column="1" Text="0.66"/><!-- need existing mean -->
		<TextBlock Grid.Row="3" Grid.Column="0" Text="Maximum"/>
		<TextBlock Grid.Row="3" Grid.Column="1" Text="1"/><!-- need existing maximum -->
		<TextBlock Grid.Row="4" Grid.Column="0" Text="Result"/>
		<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding CalculationResult}" FontWeight="Bold"/><!-- bind to my logic -->
		<Border BorderThickness="1" BorderBrush="Green" Grid.Column="1" Grid.Row="4" Grid.RowSpan="1"/>

A weird "Binding Path" construct may be?

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA

The values you are wanting to use are not currently available through any public API that you could use for binding to a tooltip like you posted, but we tested a workaround that could help you.

As noted in the documentation, a format string is available to automatically generate a string tooltip with several available values like those you mention in your sample.

If the string-based tooltip is populated with a delimited string of all those values, you can parse those values from the tooltip and use them to define your own, advanced tooltip as a replacement.

First, configure the LegendStringFormat to include the desired values and add an event handler for when the tooltip is opening:

<microcharts:MicroBoxPlot x:Name="chart" ...
    ToolTipOpening="OnToolTipOpening" />

Then in the code behind when a tooltip is opening, detect the string, parse the values, and replace the tooltip with more advanced content. The following snippet demonstrates how a grid could be dynamically generated and used to replace the default tooltip.

public void OnToolTipOpening(object sender, ToolTipEventArgs e) {
	if ((sender is MicroBoxPlot microBoxPlot) && (microBoxPlot.ToolTip is string toolTipText)) {
		// Assume MicroBoxPlot.LegendStringFormat to: {0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}
		// 0 - The minimum value.
		// 1 - The lower whisker value.
		// 2 - The first quartile value.
		// 3 - The median value.
		// 4 - The third quartile value.
		// 5 - The upper whisker value.
		// 6 - The maximum value.
		// 7 - The mean value.
		// 8 - The number of values.
		var labels = new string[] {
			"Lower Whisker",
			"First Quartile",
			"Third Quartile",
			"Upper Whisker",
			"Value Count"
		// Split the values at the delimiter
		var values = toolTipText.Split('|');

		// Dynamically create a 2-col grid with rows for each label/value pair
		var grid = new Grid();
		grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
		grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
		for (var row = 0; row < labels.Length; row++) {
			grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

			grid.Children.Add(CreateTextBlock(row, 0, labels[row]));
			grid.Children.Add(CreateTextBlock(row, 1, values[row]));

		// Replace the string-generated tooltip
		microBoxPlot.ToolTip = grid;

private TextBlock CreateTextBlock(int gridRow, int gridColumn, string text) {
	var textBlock = new TextBlock(new Run(text));
	Grid.SetRow(textBlock, gridRow);
	Grid.SetColumn(textBlock, gridColumn);
	return textBlock;

This is a crude sample that needs to be cleaned up with proper formatting and such, but does demonstrate one approach to generating a more advanced tooltip.

Sorry there is not a more elegant solution available, but I hope this workaround helps you achieve the desired result.

Actipro Software Support

Posted 2 months ago by Ralf Lieb

Thanks alot,

good enough. 

I've stuffed all in a little wrapper class

The latest build of this product (v23.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.