Why Tooltip and DataLabel Are Missing in Release Mode .NET MAUI Chart?
In .NET MAUI SfCartesianChart, tooltip and data label templates use TooltipInfo and ChartDataLabel as their binding context. These context have an Item property, which holds the corresponding business model instance used in the chart’s ItemsSource.
Starting with .NET 9.0, compiled bindings introduced via x:DataType enforce strict type scoping. This means that the tooltip or data label template operates within the scope of TooltipInfo or ChartDataLabel, and cannot directly access properties from your model unless you explicitly bind to the Item property.
To access your model’s properties, you must:
- Set x:DataType=“chart:TooltipInfo” or x:DataType=“chart:ChartDataLabel” in your template.
- Bind to Item and use a value converter to extract the desired property.
Secondly, Release mode builds enable linker trimming and AOT compilation, which can remove members referenced only from XAML. As a result, bindings that work in Debug mode may fail in Release mode unless you explicitly preserve the model and view model members.
To ensure tooltips and data labels display correctly in Release mode, follow these steps:
Step 1: Initialize the SfCartesianChart
Initialize the SfCartesianChart in your .NET MAUI application. For detailed setup instructions, refer to the documentation.
[XAML]
<chart:SfCartesianChart>
   <chart:SplineAreaSeries
       ItemsSource="{Binding ChartData}"
       XBindingPath="WeekNumber"
       YBindingPath="Planned">
       ...
   </chart:SplineAreaSeries>
</chart:SfCartesianChart> 
Step 2: Create a value converter to read the model from TooltipInfo/ChartDataLabel
This converter extracts the desired property from the Item inside TooltipInfo or ChartDataLabel.
[C#]
using System.Globalization;
public class TooltipConverter : IValueConverter
{
   public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
   {
       // value will be TooltipInfo.Item -> your actual data model instance
       if (value is Model model)
       {
           switch (parameter?.ToString())
           {
               case "Planned":
                   return model.Planned;
           }
       }
       return value;
   }
   public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => value;
} 
Step 3: Define a tooltip template using TooltipInfo scope
Use x:DataType=“chart:TooltipInfo” and bind to Item using the converter.
[C#]
<chart:SfCartesianChart ...>
 <chart:SfCartesianChart.Resources>
   <local:TooltipConverter x:Key="TooltipConverter" />
   <DataTemplate x:Key="TooltipTemplate">
     <StackLayout x:DataType="chart:TooltipInfo" Orientation="Vertical">
       <Label Text="{Binding Item,
                             Converter={StaticResource TooltipConverter},
                             ConverterParameter=Planned,
                             StringFormat='Planned : {0}h'}"
                             TextColor="White" />
     </StackLayout>
   </DataTemplate>
   
 </chart:SfCartesianChart.Resources>
</chart:SfCartesianChart> 
Step 4: Apply the tooltip template to your series
Assign the template to the TooltipTemplate property of the series. This enables the chart to use your custom layout for tooltips.
[XAML]
<chart:SplineAreaSeries
   ItemsSource="{Binding ChartData}"
   XBindingPath="WeekNumber"
   YBindingPath="Planned"
   EnableTooltip="True"
   TooltipTemplate="{StaticResource TooltipTemplate}" /> 
Step 5: Define a data label template using ChartDatalabel scope
Define a DataTemplate in Resources with x:DataType=“chart:ChartDataLabel” and bind to Item through the same converter.
[XAML]
<chart:SplineAreaSeries ...>
...
 <chart:SplineAreaSeries.DataLabelTemplate>
   <DataTemplate>
     <StackLayout x:DataType="chart:ChartDataLabel">
       <Label Text="{Binding Item, 
                             Converter={StaticResource TooltipConverter},
                             ConverterParameter=Planned,
                             StringFormat='Label : {0}h'}"
                             TextColor="Black" />
     </StackLayout>
   </DataTemplate>
 </chart:SplineAreaSeries.DataLabelTemplate>
 ...
</chart:SplineAreaSeries> 
Step 6: Apply the data label template to your series
Assign the template to LabelTemplate and enable ShowDataLabels.
[XAML]
<chart:SplineAreaSeries 
   ItemsSource="{Binding ChartData}" 
   XBindingPath="WeekNumber" 
   YBindingPath="Planned" 
   ShowDataLabels="True" 
   LabelTemplate="{StaticResource DataLabelTemplate}" />
Step 7: Preserve your ViewModel and Model classes to prevent trimming
To prevent the linker from trimming unused members in Release mode, apply the [Preserve] attribute. The example below shows iOS; apply similar preservation as needed per platform.
[C#]
using System.Collections.ObjectModel;
#if IOS
using Foundation;
#endif
#if IOS
[Preserve(AllMembers = true)]
#endif
public class ViewModel
{
   public ObservableCollection<Model> ChartData { get; } = new()
   {
       new Model { WeekNumber = 1, Planned = 3 },
       new Model { WeekNumber = 2, Planned = 5 },
       new Model { WeekNumber = 3, Planned = 2 },
       new Model { WeekNumber = 4, Planned = 5 },
       new Model { WeekNumber = 5, Planned = 7 },
   };
}
#if IOS
[Preserve(AllMembers = true)]
#endif
public class Model
{
   public double WeekNumber { get; set; }
   public double Planned { get; set; }
} 
Output:
Conclusion
I hope you enjoyed learning how to display the missing tooltip and datalabel in release mode .NET MAUI Chart (SfCartesianChart).
You can refer to our .NET MAUI Cartesian Chart’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our .NET MAUI Chart documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Chart and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
