You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In WPF, the Cartesian Chart does not allow the setting of custom tooltips in the constructor or XML
To Reproduce
Use the code and approach suggested in your online documentation for beta 700
Expected behavior
The new tooltip class being used. Instead, the default tooltip is always used.
Desktop (please complete the following information):
OS: Windows 11
Additional context
I traced this behaviour to the InitializeCore method in CartesianChart.cs within LiveChartsCore.SkiaSharpView.WPF
This method is called in the OnApplyTempate of the chart (i.e. after the constructor) and it sets the tooltip to a new SKDefaultTooltip. tooltip = new SKDefaultTooltip(); // Template.FindName("tooltip", this) as IChartTooltip<SkiaSharpDrawingContext>;
I see that the legend is also created here, meaning that this cannot be overridden in the constructor either.
Moving the lines:
legend = new SKDefaultLegend(); // Template.FindName("legend", this) as IChartLegend<SkiaSharpDrawingContext>;
tooltip = new SKDefaultTooltip(); // Template.FindName("tooltip", this) as IChartTooltip<SkiaSharpDrawingContext>;
to the constructor allows the Tooltip to be replaced in XML or the constructor as expected.
The text was updated successfully, but these errors were encountered:
Alternatively, we can leave the lines in the InitializeCore method, but check to see if they have already been assigned before overwriting them:
legend ??= new SKDefaultLegend(); // Template.FindName("legend", this) as IChartLegend<SkiaSharpDrawingContext>;
tooltip ??= new SKDefaultTooltip(); // Template.FindName("tooltip", this) as IChartTooltip<SkiaSharpDrawingContext>;
maagy
pushed a commit
to maagy/LiveCharts2
that referenced
this issue
Apr 20, 2023
Describe the bug
In WPF, the Cartesian Chart does not allow the setting of custom tooltips in the constructor or XML
To Reproduce
Use the code and approach suggested in your online documentation for beta 700
Expected behavior
The new tooltip class being used. Instead, the default tooltip is always used.
Desktop (please complete the following information):
Additional context
I traced this behaviour to the InitializeCore method in CartesianChart.cs within LiveChartsCore.SkiaSharpView.WPF
This method is called in the OnApplyTempate of the chart (i.e. after the constructor) and it sets the tooltip to a new SKDefaultTooltip.
tooltip = new SKDefaultTooltip(); // Template.FindName("tooltip", this) as IChartTooltip<SkiaSharpDrawingContext>;
I see that the legend is also created here, meaning that this cannot be overridden in the constructor either.
Moving the lines:
to the constructor allows the Tooltip to be replaced in XML or the constructor as expected.
The text was updated successfully, but these errors were encountered: