[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Collapse]Charts Suite
   [Collapse]Chart Control
    [Expand]Getting Started
    [Expand]Fundamentals
    [Expand]Providing Data
    [Expand]Chart Elements
    [Expand]Appearance Customization
    [Expand]End-User Features
    [Expand]Design-Time Features
    [Collapse]Examples
     [Expand]2D Chart Types
     [Expand]3D Chart Types
     [Expand]Providing Data
     [Expand]Data Representation
     [Collapse]Chart Elements
       How to: Plot Each XY-Series on a Separate Pane
       How to: Create and Customize Custom Axis Labels
       How to: Configure Resolve Overlapping for Axis Labels
       How to: Display Axis Labels Between Tickmarks
       How to: Show or Hide an Axis in a Multi-Pane Chart
       How to: Obtain Automatically Calculated Axis Property Values
       How to: Use Manual Date-Time Scale Options of an Axis
       How to: Use Manual Numeric Scale Options of an Axis
       How to: Add the Data Source Based Error Bars Indicator to a Chart
       How to: Add the Fixed Value Error Bars Indicator to a Chart
       How to: Add the Percentage Error Bars Indicator to a Chart
       How to: Add the Standard Deviation Error Bars Indicator to a Chart
       How to: Add the Standard Error Bars Indicator to a Chart
       How to: Add an Additional Legend
       How to: Add a Custom Legend Items to a Legend
       How to: Add a Legend Title to a Legend
       How to: Create a Scrollable Legend
       How to: Display Values Instead of Percents in the Legend
       How to: Dock an Annotation to a Chart
       How to: Dock an Annotation to a Pane
       How to: Dock an Annotation to a Series Point
       How to: Assign a Secondary X-axis to a Series
       How to: Assign a Secondary Y-axis to a Series
       How to: Generate a Chart by its ViewModel
     [Expand]Appearance Customization
     [Expand]End-User Interaction
     [Expand]Miscellaneous
    [Expand]Additional Resources
   [Expand]Chart3D Control
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Generate a Chart by its ViewModel

The Chart Control can generate its child elements from their ViewModels. This is useful when the application uses the MVVM architecture and the Chart should contain several chart elements that are bound to data. You can bind the element's ItemsSource to the View Model's property to generate a chart element collection from a chart's View Model. Then specify the element's ItemTemplate or ItemTemplateSelector to bind the element's properties to the element view model's properties. For example, you can bind a chart's legend collection to the view model's legend collection using the ChartControlBase.LegendItemsSource and configure the generated legends using the ChartControlBase.LegendItemTemplate.

Below is a list of properties that allow you to generate chart elements from view models:

Symbol Description
Annotations
ChartControl.AnnotationItemsSource Gets or sets the collection of objects used to generate annotations.
ChartControl.AnnotationItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to an annotation.
ChartControl.AnnotationItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to an annotation.
Legends
ChartControlBase.LegendItemsSource Gets or sets the collection of objects used to generate legends.
ChartControlBase.LegendItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a legend.
ChartControlBase.LegendItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a legend.
Series
Diagram.SeriesItemsSource Gets or sets the collection of objects used to generate series.
Diagram.SeriesItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a series.
Diagram.SeriesItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a series.
Secondary Axes
XYDiagram2D.SecondaryAxisXItemsSource Gets or sets the collection used to generate secondary X-axes.
XYDiagram2D.SecondaryAxisXItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a secondary X-axis.
XYDiagram2D.SecondaryAxisXItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a secondary X-axis.
XYDiagram2D.SecondaryAxisYItemsSource Gets or sets the collection used to generate secondary Y-axes.
XYDiagram2D.SecondaryAxisYItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a secondary Y-axis.
XYDiagram2D.SecondaryAxisYItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a secondary Y-axis.
Panes
XYDiagram2D.PaneItemsSource Gets or sets the collection of objects used to generate panes.
XYDiagram2D.PaneItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a pane.
XYDiagram2D.PaneItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a pane.
Custom Axis Labels
Axis2D.CustomLabelItemsSource Gets or sets the collection used to generate custom labels.
Axis2D.CustomLabelItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a custom label.
Axis2D.CustomLabelItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a custom label.
Constant Lines
Axis2D.ConstantLineBehindItemsSource Gets or sets the collection of objects used to generate constant lines that are positioned behind series.
Axis2D.ConstantLineBehindItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a constant line that is positioned behind series.
Axis2D.ConstantLineBehindItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a constant line positioned behind series.
Axis2D.ConstantLineInFrontItemsSource Gets or sets the collection of objects used to generate constant lines that are positioned in front of series.
Axis2D.ConstantLineInFrontItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a constant line that is positioned in front of series.
Axis2D.ConstantLineInFrontItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a constant line positioned in front of series.
Strips
Axis2D.StripItemsSource Gets or sets the collection of objects used to generate strips.
Axis2D.StripItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a strip.
Axis2D.StripItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a strip.
Scale Breaks
Axis2D.ScaleBreakItemsSource Gets or sets the collection of objects used to generate scale breaks.
Axis2D.ScaleBreakItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a scale break.
Axis2D.ScaleBreakItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a scale break.
Visibility in Panes
Axis2D.VisibilityInPaneItemsSource Gets or sets the collection of objects used to generate the axis's VisibilityInPane items.
Axis2D.VisibilityInPaneItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a VisibilityInPane object.
Axis2D.VisibilityInPaneItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a VisibilityInPane object.
Indicators
XYSeries2D.IndicatorItemsSource Gets or sets the collection of objects used to generate series' indicators.
XYSeries2D.IndicatorItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to an indicator.
XYSeries2D.IndicatorItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to an indicator.
Custom Legend Items
Legend.CustomItemsSource Gets or sets the collection of objects used to generate custom legend items.
Legend.CustomItemTemplate Gets or sets the System.Windows.DataTemplate that specifies how to convert a model object to a custom legend item.
Legend.CustomItemTemplateSelector Gets or sets the custom logic for selecting a data template that converts a model object to a legend custom item.

Is this topic helpful?​​​​​​​