Articles in this section
Category / Section

How to add WPF SfChart inside the SfDataGrid?

3 mins read

The following steps describe how to add the WPF Chart inside the SfDataGrid.

Step 1: Create an instance of the GridTemplateColumn class, and add it to the Columns property in the SfDataGrid to display the custom content specified in the CellTemplate.




Step 2: Then, add the SfChart control to the CellTemplate property as custom template content as demonstrated in then following code sample.


            <local:ItemsSourceConverter x:Key="converter" />
            <local:MaximumConverter x:Key="maximumConverter" />
              <chart:SfChart SideBySideSeriesPlacement="False">
                       <chart:ChartColumnDefinition />
                       <chart:ChartColumnDefinition />
                       <chart:NumericalAxis IsInversed="True" ShowGridLines="False" Visibility="Collapsed" />
                        <chart:NumericalAxis IsInversed="True" Maximum="{Binding Maximum}"
                            ShowGridLines="False" Visibility="Collapsed" />
                  <chart:BarSeries Interior="LawnGreen" XBindingPath="XValue"
                   ItemsSource="{Binding., Converter={StaticResource converter}}" YBindingPath="YValue1">
                  <chart:BarSeries Interior="Red" XBindingPath="XValue" YBindingPath="YValue2"
                             ItemsSource="{Binding., Converter={StaticResource converter}}">
                            <chart:NumericalAxis ShowGridLines="False" Maximum="{Binding Maximum}"
                                  chart:ChartBase.Column="1" Visibility="Collapsed" />



public class ItemsSourceConverter : IValueConverter
     public object Convert(object values, Type targetType, object parameter, CultureInfo culture)
          var data = values as OrderInfo;
          var collection = new ObservableCollection<Model>();
          Model model = new Model() { XValue = data.XValue, YValue1 = data.YValue1, YValue2 = data.YValue2 };
          return collection;
      object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
           return value;



SfChart inside the SfDatagrid cell


I hope you enjoyed learning about how to add WPF SfChart inside the SfDataGrid.

You can refer to our WPF Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Chart example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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