From 330e314f407fe92c227e46733675846bf9100fcc Mon Sep 17 00:00:00 2001 From: AswiniDileep Date: Thu, 30 Oct 2025 16:08:17 +0530 Subject: [PATCH 1/3] MAUI-988662-[Others]: Updated UG content for KB --- maui-toolkit-toc.html | 1 + ...play-tooltip-datalabels-in-release-mode.md | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md diff --git a/maui-toolkit-toc.html b/maui-toolkit-toc.html index be427528..86040038 100644 --- a/maui-toolkit-toc.html +++ b/maui-toolkit-toc.html @@ -168,6 +168,7 @@
  • Add custom labels to the chart axis
  • Customize each chart axis label using the callback event
  • Get the data point collection based on region
  • +
  • Display tooltip and datalabels in release mode
  • diff --git a/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md b/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md new file mode 100644 index 00000000..d87ee1d7 --- /dev/null +++ b/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md @@ -0,0 +1,73 @@ +--- +layout: post +title: Show tooltip and datalabels in release mode | Syncfusion +description: Learn here all about displaying tooltip and datalabels in release mode in SfCartesianChart in Syncfusion® .NET MAUI Chart (SfCartesianChart) control. +platform: maui-toolkit +control: SfCartesianChart +documentation: ug +keywords: .NET MAUI chart tooltip, .NET MAUI chart data label, TooltipInfo Item binding, ChartDataLabel Item binding, Release mode trimming, Preserve attribute MAUI. +--- + +# Display tooltip and data labels in release mode + +The binding context inside tooltip and data labels templates is not your model directly. These templates run in the scope of [TooltipInfo](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.TooltipInfo.html) and [ChartDataLabel](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartDataLabel.html), which expose an `Item` property that contains the actual data model from the charts [ItemsSource](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSeries.html#Syncfusion_Maui_Charts_ChartSeries_ItemsSource). To read your model’s fields in a template, bind through Item or use a converter. + + +With .NET 9 compiled bindings, tooltip templates run with **x:DataType="chart:TooltipInfo"** and data label templates run with **x:DataType="chart:ChartDataLabel"**. Inside these templates, bind to the model via the Item property. Use a value converter to pull the required field from Item. In Release builds, trimming/AOT can remove XAML-only types, so preserve your ViewModel, Model, and the converter to keep these bindings working. + + +{% highlight xaml %} + + + ..... + + + + + + + + + + + + + + + + +{% endhighlight %} + + +{% highlight C# %} + + public class TooltipConverter : IValueConverter + { + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + // value is TooltipInfo.Item or ChartDataLabel.Item -> your Model + if (value is Model model && parameter?.ToString() == "Planned") + return model.Planned; + + return value; + } + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => value; + } + +{% endhighlight %} + +## See also + +[How to display tooltip and data labels in release mode .NET MAUI SfCartesianChart](https://support.syncfusion.com/kb/article/21677/why-tooltip-and-datalabel-are-not-showing-in-release-mode-in-net-maui-sfcartesianchart) \ No newline at end of file From 38da21362f4c0859a7848a80e04da36dc5d23b83 Mon Sep 17 00:00:00 2001 From: AswiniDileep Date: Wed, 5 Nov 2025 10:35:55 +0530 Subject: [PATCH 2/3] MAUI-988662-[Others]: Updated UG with proper code lines --- ...play-tooltip-datalabels-in-release-mode.md | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md b/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md index d87ee1d7..b9fc88cd 100644 --- a/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md +++ b/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md @@ -19,33 +19,38 @@ With .NET 9 compiled bindings, tooltip templates run with **x:DataType="chart:To {% highlight xaml %} - ..... - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + {% endhighlight %} @@ -53,7 +58,7 @@ With .NET 9 compiled bindings, tooltip templates run with **x:DataType="chart:To {% highlight C# %} - public class TooltipConverter : IValueConverter + public class ValueConverter : IValueConverter { public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { From 82ae4be80476f0b81f341d4e904a7064c1558650 Mon Sep 17 00:00:00 2001 From: AswiniDileep Date: Tue, 2 Dec 2025 19:18:01 +0530 Subject: [PATCH 3/3] Addressed review suggestions --- maui-toolkit-toc.html | 2 +- ...ata-labels-not-visible-in-release-mode.md} | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) rename maui-toolkit/Cartesian-Charts/{Display-tooltip-datalabels-in-release-mode.md => Why-tooltip-and-data-labels-not-visible-in-release-mode.md} (57%) diff --git a/maui-toolkit-toc.html b/maui-toolkit-toc.html index 86040038..779c31ef 100644 --- a/maui-toolkit-toc.html +++ b/maui-toolkit-toc.html @@ -168,7 +168,7 @@
  • Add custom labels to the chart axis
  • Customize each chart axis label using the callback event
  • Get the data point collection based on region
  • -
  • Display tooltip and datalabels in release mode
  • +
  • Why tooltip and data labels not visible in release mode
  • diff --git a/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md b/maui-toolkit/Cartesian-Charts/Why-tooltip-and-data-labels-not-visible-in-release-mode.md similarity index 57% rename from maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md rename to maui-toolkit/Cartesian-Charts/Why-tooltip-and-data-labels-not-visible-in-release-mode.md index b9fc88cd..f42fb175 100644 --- a/maui-toolkit/Cartesian-Charts/Display-tooltip-datalabels-in-release-mode.md +++ b/maui-toolkit/Cartesian-Charts/Why-tooltip-and-data-labels-not-visible-in-release-mode.md @@ -10,10 +10,14 @@ keywords: .NET MAUI chart tooltip, .NET MAUI chart data label, TooltipInfo Item # Display tooltip and data labels in release mode -The binding context inside tooltip and data labels templates is not your model directly. These templates run in the scope of [TooltipInfo](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.TooltipInfo.html) and [ChartDataLabel](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartDataLabel.html), which expose an `Item` property that contains the actual data model from the charts [ItemsSource](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSeries.html#Syncfusion_Maui_Charts_ChartSeries_ItemsSource). To read your model’s fields in a template, bind through Item or use a converter. +In [SfCartesianChart](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.SfCartesianChart.html), the binding context inside tooltip and data label templates is not your business model directly. These templates run with Chart specific contexts. +* Tooltip template: chart:[TooltipInfo](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.TooltipInfo.html) +* Data label template: chart:[ChartDataLabel](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.ChartDataLabel.html) -With .NET 9 compiled bindings, tooltip templates run with **x:DataType="chart:TooltipInfo"** and data label templates run with **x:DataType="chart:ChartDataLabel"**. Inside these templates, bind to the model via the Item property. Use a value converter to pull the required field from Item. In Release builds, trimming/AOT can remove XAML-only types, so preserve your ViewModel, Model, and the converter to keep these bindings working. +Both provide an `Item` property that references the actual data object from the series [ItemsSource](https://help.syncfusion.com/cr/maui-toolkit/Syncfusion.Maui.Toolkit.Charts.ChartSeries.html#Syncfusion_Maui_Toolkit_Charts_ChartSeries_ItemsSourceProperty). Bind your fields through Item to display values from your business model. + +Release builds can remove types that are referenced only from XAML. To prevent this, reference a value converter from XAML and preserve your ViewModel, business model, and converter classes. With .NET 9 compiled bindings, set **x:DataType="chart:TooltipInfo"** for tooltip templates and **x:DataType="chart:ChartDataLabel"** for data label templates, then bind via Item. Use the converter to extract the required property from Item. {% highlight xaml %} @@ -60,19 +64,16 @@ With .NET 9 compiled bindings, tooltip templates run with **x:DataType="chart:To public class ValueConverter : IValueConverter { - public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - // value is TooltipInfo.Item or ChartDataLabel.Item -> your Model - if (value is Model model && parameter?.ToString() == "Planned") - return model.Planned; - - return value; + return value is WeekPlan weekPlan ? weekPlan.Planned : value; } - public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => value; + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => value; } {% endhighlight %} ## See also -[How to display tooltip and data labels in release mode .NET MAUI SfCartesianChart](https://support.syncfusion.com/kb/article/21677/why-tooltip-and-datalabel-are-not-showing-in-release-mode-in-net-maui-sfcartesianchart) \ No newline at end of file +[Why Tooltip and DataLabel Are Missing in Release Mode .NET MAUI Chart?](https://support.syncfusion.com/kb/article/21677/why-tooltip-and-datalabel-are-not-showing-in-release-mode-in-net-maui-sfcartesianchart) \ No newline at end of file