We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

chart not updating when placed in usercontrol

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 





3 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team November 9, 2016 09:25 AM UTC

Hi Stephan, 
  
Thanks for contacting Syncfusion Support. 
  
We have analyzed the problem with your reference code and we are unable to reproduce the problem. We have prepared the sample based on your requirement (dynamic addition of data to both the SfChart in main window and in the UserControl) and please find the sample below. 
  
Sample:  UserControlDemo 
  
Regards, 
Devi 





SP stephan putz November 11, 2016 06:45 AM UTC

Thank you, I look and check and try again.
Stephan


DA Devi Aruna Maharasi Murugan Syncfusion Team November 14, 2016 03:54 AM UTC

Hi Stephan, 
  
Thanks for the update. 
  
We will wait to hear from you. 
  
Regards, 
Preethi  


Loader.
Up arrow icon