Data Binding Change Notification

3 posts, 0 answers
  1. Rav Panchalingam
    Rav Panchalingam avatar
    3 posts
    Member since:
    Jul 2009

    Posted 27 Jul 2009 Link to this post

    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. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 28 Jul 2009 Link to this post

    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.
  3. Liberte
    Liberte avatar
    6 posts
    Member since:
    Jul 2008

    Posted 28 Jul 2009 Link to this post

    How About that:
    1 public partial class MainWindow : Window 
    2     { 
    3         ObservableCollection<double> data = new ObservableCollection<double>(); 
    4  
    5         public MainWindow() 
    6         { 
    7             this.InitializeComponent();             
    8             RadChart1.DataContext = data; 
    9             SetData(); 
    10         } 
    11  
    12         private void SetData() 
    13         { 
    14             data.Clear(); 
    15             Random rnd = new Random(); 
    16             for (int i = 1; i <= 10; i++) 
    17             { 
    18                 data.Add((int)(rnd.NextDouble() * 10)); 
    19             } 
    20         } 
    21  
    22         private void Button_Click(object sender, RoutedEventArgs e) 
    23         { 
    24             SetData(); 
    25         } 
    26     } 
    and the Xaml:
    1 <Grid x:Name="LayoutRoot"
    2         <control:RadChart x:Name="RadChart1" ItemsSource="{Binding}"/> 
    3         <Button Content="Change Data" Click="Button_Click"  
    4                 VerticalAlignment="Center" HorizontalAlignment="Right"  
    5                 Width="100" Height="25"/>  
    6     </Grid> 
    so now... when we change the collection, chart is updated properly :}  ObservableCollection is a very handy stuff :}
Back to Top