Binding chart to observable collection and removing items

Nov 10, 2012 at 7:22 PM

When I bind a chart to an observable collection and add items it works fine. However, when I remove items parts of the chart will redraw (like the line in a line series), but the datapoint stays on the screen. Maybe I'm doing something wrong, but my code is really just the same as the examples with the NameValueItem as an ObservableCollection instead of a List.

I've tried calling UpdateLayout, but that does not seem to make a difference.

Refresh actually causes all of the datapoints to be left on screen.

Nov 14, 2012 at 5:10 PM


Nov 14, 2012 at 5:12 PM

Sorry, I don't have the time to debug it right now unless you can share a sample project. It could be a bug in the controls of course. You have the source code though, so you could try checking what is going on yourself if no one here can help you.

Nov 14, 2012 at 7:25 PM

I have a sample project I can upload, I'll do that later this evening.

I don't have enough experience to debug the controls myself unfortunately. I have tried, and bound to an ObservableCollection with 5 items, with a check on adding items that should keep the item list at a max of 5 and always remove the item at index 0. I can see that the bound series always appears to have five points, but the actual data point for item 0 never gets removed from the screen when the item is removed from the collection - it continues to have a tooltip and everything.

Anyways, like I said I'll upload the project later this evening - it's a very simple project that really only has the chart and a couple of ways to add items to it.

In the end what I was aiming for was a chart that could show the speed of a network transfer over the last 30 seconds or so, just FYI.

Nov 15, 2012 at 2:31 AM
Edited Nov 15, 2012 at 7:23 PM

Not sure if this will work, I'm not all that handy with skydrive as of yet:!263&authkey=!AGAvJtSRLILIzHc


I updated the project and the link above. I've taken my class and now derived from BindableBase. I've also added a list view to show that adding/removing/modifying items in the ObservableCollection works fine and updates the ListView accordingly. The datapoint issue still exists with the chart, and further to that when you modify an item in the collection that the chart is bound to it throws a COMException coming from the BindableBase OnPropertyChanged method.

Nov 15, 2012 at 7:42 PM

I also added an issue to the issue tracker with the same project above attached.

Nov 21, 2012 at 2:14 AM

I give up, doesn't seem there's much activity within this project, or the original chart project it's based on. Non-commercial controls for WinRT XAML are looking pretty sparse at this point, and WPF is so much easier and more capable. I'd love to be able to dig in and fix the issues myself, but that's just not something I'm knowledgeable enough to do at the moment.

Nov 25, 2012 at 7:04 AM

Sorry, I have been busy, but I did start looking into this.

It seems like the DataPointSeries class has a StaggeredStateChange method that is supposed to run state transitions to make the data points appear/disappear, but it seems like the first Storyboard that is supposed to switch the State property value to DataPointState.Showing fails to start and so later the StoryboardQueue can't Dequeue the transition to Hiding, which prevents the DataPoints from hiding. I am not yet sure why this happens. I made sure the animations have EnableDependentAnimation set to true, but I still get a System.Exception with a cryptic message: "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))" when dequeuing the storyboard.

I'll see if I can push it farther, but it's not clear if I can do it quickly.

Nov 28, 2012 at 3:15 PM

Hey xyzzer,

Thanks for looking into this...

I myself have kind of lost interest in WinRT, most of what I wanted to do would have gone over a VPN connection and it seems there's no VPN connectivity from WinRT

Nov 28, 2012 at 4:30 PM

To each his own, I guess. I think I heard something about VPN being supported if you use Microsoft's VPN tools (DirectAccess?). I am using Cisco, but on a laptop with full Windows 8, not Windows RT. I think if you need VPN - you just shouldn't use a Windows RT device at least until they figure it out.

I gave up working on that bug for now. There might be a simple quick workaround if you just don't use Storyboards and simply hide/remove the data points. I don't have the time to work on it now though.

Dec 4, 2012 at 11:34 PM

Actually we're not using WinRT 'devices', just Win8 and Cisco - still no access to VPN network from anywhere in 'Metro'/WinRT though.

Dec 4, 2012 at 11:36 PM

Strange, I am using Win8 and Cisco and VPN works fine.

Dec 4, 2012 at 11:38 PM

Granted - I don't run any Metro apps that would require the use of intranet, but intranet works fine on the desktop and it works fine from the Metro IE.

Dec 6, 2012 at 5:26 PM

I've never tried Metro IE. The Metro Remote Desktop was where we first noticed the issue. I haven't really been able to get any clarification on whether Metro apps can communicate over a Cisco VPN from anyone at MS, but others posting on MSDN/TechNet seem to indicate that they can't get it to work. Maybe HTTP/HTTPS is an exception...

Dec 12, 2012 at 5:15 AM


I am using this toolkit to create charts. The charts are bound to an observable collection and need to be updated when the data it is bound to changes. The charts do get updated, but as mentioned in the above known bug, the data points do not get removed. Hiding the data points do not serve the purpose. Hence I need to show the data points which have to be removed when collection changes.

Kindly let me know if there is any fix for this bug or any work around is possible.

Dec 12, 2012 at 5:38 AM

The workaround I know if is to remove and recreate the chart control.

From what I could find - this is the line that is causing the failure:

storyboard.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => storyboard.Begin());

I haven't had the time to debug it to the end to see what's wrong with it, but it seems to be preventing an animation that shows or hides the datapoint from completion and the datapoint is only going to be removed when it completes. If you want to debug it and help fix it for everyone - that's where you could start.

Right now I am busy with some other projects, sorry.

Dec 26, 2012 at 7:51 PM

I'm hitting the same problem. I have a couple of LineSeries declared in XAML that are each bound to their own Lists. When I change the lists and notify that there was a change, I see the same exception in the debugger and both the new series and the old series appear on the chart. Only the new series appears to still be wired up to all the animations. I also haven't been able to get to the bottom of this but its making it quite difficult to use the chart control in any way except to draw things once. Thought I'd add a ref count to this thread. If I find time to debug further I will...

Dec 27, 2012 at 11:06 PM

I was able to fix this by casting the type of the state property used for that animation to an int and making sure that everywhere that sets it does the same. Looks like WinRT can't animate using a dependency property with an enum type.

The change was in the definition of the DependencyProperty where I defined the type as int and cast the default to int.

/// <summary>
/// Identifies the State dependency property.
/// </summary>
internal static readonly DependencyProperty StateProperty =
new PropertyMetadata((int)DataPointState.Created, OnStatePropertyChanged));

And in private void StaggeredStateChange(IEnumerable<DataPoint> dataPoints, int dataPointCount, DataPointState newState)

Add the cast to int before casting to object.
discreteObjectKeyFrame.Value = (object)((int)newState);

Dec 27, 2012 at 11:07 PM

Great, thanks! I will update the code and submit the change soon.

Apr 21, 2013 at 4:56 PM
Hello and great toolkit! Thank you.
I do not have problems with animations but i have noticed that if i am switching between databound Lineseries in xaml and one does not contain any items, the line is not removed from the chart although the datapoints are hidden.
I worked around this by adding a 0 value datapoint in the observablecollection if the count is 0 and reassigning the itemssource in code behind.
I assume this is a bug. Could I be notified when a fix is implemented? or am I doing something wrong?

Thank you!! :-)