Jump to content
Software FX Community

CondtionalAttributes seems to throw an exception in a real time chart.


Recommended Posts


I made a real time chart binding ItemsSource to a ObservablCollection with a limited buffer size.

I used Dispatcher.Invoke method for removing and adding items to keep the buffer size.

It worked fine until I added a conditional attribute to the chart.

It seemed it throws this TargetInvocationException when a new data meets the condition.

Am I using this wrong?

  int buffersize = 20;

  ObservableCollection <ChartData> DataSource = new ObservableCollection<ChartData>();

  delegate void RemoveAtListArrayDelegate(int index);

  delegate void AddListArrayDelegate(ChartData cd);

  public void SetRunChart()


  RunChart.Animation.OnDataChange = false;

  RunChart.ItemsSource = DataSource;

  SeriesAttributes sa = new SeriesAttributes("Data");

  sa.Gallery = Gallery.Line;


  RunChart.AxisX.Labels.BindingPath = "XValue";

  RunChart.AxisY.ForceZero = true;


public void AddData(ChartData cd)


  if (DataSource.Count > buffersize)


  RemoveAtListArrayDelegate removeItem = new RemoveAtListArrayDelegate(DataSource.RemoveAt);

  Dispatcher.Invoke(removeItem, new object[] { 0 });


  AddListArrayDelegate addItem = new AddListArrayDelegate(DataSource.Add);

  Dispatcher.Invoke(addItem, new object[] { cd });




I used Google Chrome for the last post "ZoomMode.Off, it didn't work", but apparently Chrome didn't support editing tool bar as IE does.

Sorry for the messed message. It's about implementing a countinuous zooming method.

Link to comment
Share on other sites

We have been unable to reproduce the problem in a sample app where we can add and remove buttons using an ObservableCollection, we tested adding points that do and do not meet the conditions as well as removing points and it seemed to work fine. Note that we executed these in the UI thread directly and not using Dispatcher.Invoke

Can you try to isolate a test case in a separate app? You might be able reproduce it using dummy data.



Link to comment
Share on other sites


I've isolated this case in a separate application which is attatched.

Have you tried to remove the first item in an ObservablCollection array not only adding new one? Try attatched app with and without the statement for removing the first item in the array.

(The first item has to be removed to keep the size of displaying points.)

I don't know why but it seems the execption is thrown when the first item is removed.

Without using condiotional attributes, it really works fine.

What should I do to avoid this conflict?




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...