My XamChart as 3 series which is binded with this.DataContext (CurrentPriceObj.PriceTrend which is a DataTable). When I got the onChange event fire I Invoke CurrentPrice .doCalculation which is simply adding a datarow. I pass back the datatable to a new LivePrice Class and invoke the new this.DataContext.
Everything works like a charge until this. Since the XamChart has a limited number or point that can be seen, I have to remove some datarow in my datatble during doCalculation. I Accept the changes of course and my XamChart does not appear anymore. And I do not have any error poping up.
What could possibly be wrong.
void _onChange(Addin_MktPrice_Interface.Change Changes) { try { CurrentPrice.RealPrice = (Addin_MktPrice_Interface.MarketPrice)Changes.Values; this.Dispatcher.BeginInvoke(new Action(() => CurrentPrice.doCalculation()), null);
LivePrice CurrentPriceObj = new LivePrice(); CurrentPriceObj.PriceTrend = CurrentPrice.PriceTrend; this.Dispatcher.BeginInvoke(new Action(() => this.DataContext = CurrentPriceObj), null);
GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
Hello,
I have been looking into your description however I am not able to figure out what might be the cause of your issue. I was wondering if you could please provide me with a sample I can continue my investigation.
Thanks in advance. Looking forward to hearing from you.
Attached is a very simple sample with the XamChart and one button.
Click on the button and it add one row into the datatable. When reaching 10 rows I remove the last row. This when xamchart disappear.
The xamchart is binded to the tabe.
Thanks
I was able to reproduce the behavior you described, however when I commented out the
//PriceTrend.AcceptChanges();
line from your doCalculation() method everything seemed to work as expected.
Please let me know if I can be of any further assistance.
I had thought on updating the server from this DataTable however the XamChart is not actually a control that would have modified the data and in turn send an update to its data source. Nevertheless I was also going to suggest the XamDataChart, since the XamChart is soon to be retired. You can look into this blog post to for further reference: http://blogs.infragistics.com/blogs/jason_beres/archive/2011/11/10/important-product-changes-and-control-retirements-in-2011-2.aspx .
It does work by commenting out the "AcceptChanges" but it's strange that it act like this only when removing rows where it does not affect the add row.
To return this datatable to the database or binding, it may have some negative impact. Don't you think?
However, the same code works great on the xamDataChart.