Articles in this section
Category / Section

How to bind the array property in WPF Chart (SfChart)?

1 min read

WPF Chart (SfChart) supports array values for the XBindingPath and YBindingPath. The XBindingPath and YBindingPath are bound with the property name in the corresponding index value. You can bind the same property with different index values.

public class TestClass
{
  public double X { get; set; }
  public double[] Y { get; set; }
}
public class TestClassCollection : ObservableCollection<TestClass>
{
  public TestClassCollection()
  {
    this.Add(new TestClass { X = 1, Y = new double[] { 4, 10 } });
    this.Add(new TestClass { X = 2, Y = new double[] { 8, 15 } });
    this.Add(new TestClass { X = 3, Y = new double[] { 12,20 } });
  }
}

XAML

<chart:ColumnSeries ItemsSource="{Binding}" XBindingPath="X" YBindingPath="Y[0]">
</chart:ColumnSeries>

C#

ColumnSeries series = new ColumnSeries() { XBindingPath = "X", YBindingPath = "Y[0]"};

 

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