I'm having an annoying problem: I have a simple Chart with one ColumnSeries and two axis (a LinearAxis for the dependent value and a DateTimeAxis for the independent one). My ColumnSeries' ItemsSource is bound to a Collection of instances of DataPoint (simple class with only 3 properties: Date, IndependentValue and DependentValue). The Chart displays the columns correctly if the Collection has 2 or more items in it; but if it only has one, it won't show any column.
Any ideas on what's going on?
Here's the XAML (with both standard and WPF Toolkit's namespaces omitted for brevity):
<Window x:Class="Demo.MainWindow" (...) xmlns:local="clr-namespace:Demo">
<Grid>
<Grid.Resources>
<local:DataPointCollection x:Key="DataPointCollection" />
</Grid.Resources>
<ct:Chart Title="Demo">
<ct:ColumnSeries Title="A"
ItemsSource="{StaticResource DataPointCollection}"
IndependentValueBinding="{Binding Date}"
DependentValueBinding="{Binding DependentValue}" />
<ct:Chart.Axes>
<ct:LinearAxis Orientation="Y"
ShowGridLines="True"
Title="Dependent Title" />
<ct:DateTimeAxis Orientation=X"
ShowGridLines="True"
Interval="1"
IntervalType="Days" />
</ct:Chart.Axes>
</ct:Chart>
</Grid>
</Window>
The DataPointCollection class:
using System;
namespace Demo
{
using System.Collections.ObjectModel;
public class DataPointCollection: Collection<DataPoint>
{
public DataPointCollection()
{
Add(new DataPoint { Date = DateTime.Now.Date, DependentValue = 5 });
// Comment next line to see an empty chart:
Add(new DataPoint { Date = DateTime.Now.Date.AddDays(1), DependentValue = 6 });
}
}
}
And the DataPoint class:
using System;
namespace Demo
{
public class DataPoint
{
public DateTime Date { get; set; }
public double DependentValue { get; set; }
}
}
The project is a regular WPF Application (WPF 4).
Thanks in advance.