Hello,
first sfChart placed direct into WPF Window with bound Itemsource to ViewModel works well.
second sfChart placed on a usercontrol an placed in same WPF Window. It Display data at program start = OK.
If data added to ObservableCollection first sfChart update the view and show new added data,
second sfChart inside usercontrol does not update.
Chart inside Window:
<chart:SfChart Grid.Column="1" Grid.Row="0" x:Name="Chart2" Header="Binding View Model" HorizontalAlignment="Center" Margin="10" VerticalAlignment="Center">
<chart:SfChart.PrimaryAxis>
<chart:NumericalAxis FontSize="10" Header="X - Position"
ShowGridLines="True"
EnableTouchMode="True"
EnableScrollBar="True" />
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis FontSize="10" Header="Sin Height" Maximum="50" Minimum="-10" ShowGridLines="True"/>
</chart:SfChart.SecondaryAxis>
<chart:FastLineBitmapSeries x:Name="SinLineSeries2"
ItemsSource="{Binding Data}"
EnableAntiAliasing="True"
XBindingPath="Position" YBindingPath="Value"
LegendIcon="SeriesType" StrokeThickness="2">
</chart:FastLineBitmapSeries>
<chart:FastScatterBitmapSeries x:Name="SinScatterSeries2"
ItemsSource="{Binding Data}"
ScatterHeight="5" ScatterWidth="5"
Palette="Metro"
XBindingPath="Position" YBindingPath="Value"
LegendIcon="SeriesType" StrokeThickness="2"/>
</chart:SfChart>
Usercontrol:
<usercontrol:ChartCtrl x:Name="ChartCtrl" Grid.Column="2" Grid.Row="0"></usercontrol:ChartCtrl>
Usercontrol Inside:
<chart:SfChart x:Name="ChartControl" Header="UserControl" HorizontalAlignment="Center" Margin="10" VerticalAlignment="Center">
<chart:SfChart.PrimaryAxis>
<chart:NumericalAxis FontSize="10" Header="X - Position"
ShowGridLines="True"
EnableTouchMode="True"
EnableScrollBar="True" />
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis FontSize="10" Header="Sin Height" Maximum="50" Minimum="-10" ShowGridLines="True"/>
</chart:SfChart.SecondaryAxis>
<chart:FastLineBitmapSeries x:Name="SinLineSeries3"
EnableAntiAliasing="True"
XBindingPath="Position" YBindingPath="Value"
LegendIcon="SeriesType" StrokeThickness="2">
</chart:FastLineBitmapSeries>
<chart:FastScatterBitmapSeries x:Name="SinScatterSeries3"
ScatterHeight="4" ScatterWidth="3"
Palette="Metro"
XBindingPath="Position" YBindingPath="Value"
LegendIcon="SeriesType" StrokeThickness="2"/>
</chart:SfChart>
CodeBehind:
....
var ctx = new MainViewModel();
this.DataContext = ctx;
ChartCtrl.DataContext = ctx;
ChartCtrl.SinLineSeries3.ItemsSource = ctx.Data;
ChartCtrl.SinScatterSeries3.ItemsSource = ctx.Data;
....
ViewModel:
private ObservableCollection<Sample> data;
public ObservableCollection<Sample> Data { get { return data; } set { data = value; } }
ctor
Data = new ObservableCollection<Sample>();
FillWithDummySinus(Data);
After program Start, first and second Chart show same dummydata. After adding data to the collection, only first Chart Changes and show new data too.
I tried a lot of different variant in XAML Binding but no success.
Any Idea whats wrong or how it works?
Thx
stephan