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.
Unfortunately, activation email could not send to your email. Please try again.

chart not updating when placed in usercontrol

Thread ID:

Created:

Updated:

Platform:

Replies:

127279 Nov 8,2016 03:56 AM Nov 13,2016 10:54 PM WPF 3
loading
Tags: Chart
stephan putz
Asked On November 8, 2016 03:56 AM

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 





Devi Aruna Maharasi Murugan [Syncfusion]
Replied On November 9, 2016 04:25 AM

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 




stephan putz
Replied On November 11, 2016 01:45 AM

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

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On November 13, 2016 10:54 PM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;