This is a migrated thread and some comments may be shown as answers.

Data Binding Change Notification

2 Answers 50 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Rav Panchalingam
Top achievements
Rank 1
Rav Panchalingam asked on 28 Jul 2009, 03:45 AM
Hi,

I have read in documentation that RadCharts supports binding to a data source with change notification. I assume this means, when a change is made to that data type it will automatically reflect on the graph? I havent been able to succesfully implement this using an ArrayList. Is there a sample application available?

Regards

Rav

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 28 Jul 2009, 05:26 AM
Hi Rav,

I don't think that you will get any change notifications from simple ArrayList - you will need INotifyCollectionChanged!

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Liberte
Top achievements
Rank 1
answered on 28 Jul 2009, 08:22 AM
How About that:
public partial class MainWindow : Window 
    { 
        ObservableCollection<double> data = new ObservableCollection<double>(); 
 
        public MainWindow() 
        { 
            this.InitializeComponent();             
            RadChart1.DataContext = data; 
            SetData(); 
        } 
 
        private void SetData() 
        { 
            data.Clear(); 
            Random rnd = new Random(); 
            for (int i = 1; i <= 10; i++) 
            { 
                data.Add((int)(rnd.NextDouble() * 10)); 
            } 
        } 
 
        private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            SetData(); 
        } 
    } 
and the Xaml:
<Grid x:Name="LayoutRoot"
        <control:RadChart x:Name="RadChart1" ItemsSource="{Binding}"/> 
        <Button Content="Change Data" Click="Button_Click"  
                VerticalAlignment="Center" HorizontalAlignment="Right"  
                Width="100" Height="25"/>  
    </Grid> 
so now... when we change the collection, chart is updated properly :}  ObservableCollection is a very handy stuff :}
Tags
Chart
Asked by
Rav Panchalingam
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Liberte
Top achievements
Rank 1
Share this question
or