0
votes

I am doing a Windows Phone 7 application, it uses a calender control from namespace System.Windows.Controls. My calender control is placed inside the TabControl from the same namespace.

When I select a date am getting following "NotSupportedException" message saying :

"This type of Collection does not support changes to its SourceCollection from a thread different from the Dispatcher thread."

What could be the reason for this type of error and could i have a solution for this?enter image description here

Exception details : System.NotSupportedException was unhandled Message=This type of Collection does not support changes to its SourceCollection from a thread different from the Dispatcher thread. StackTrace: at System.Windows.Controls.SelectedDatesCollection.InsertItem(Int32 index, DateTime item) at System.Collections.ObjectModel.Collection`1.Add(DateTime item) at System.Windows.Controls.SelectedDatesCollection.AddRange(DateTime start, DateTime end) at System.Windows.Controls.Primitives.CalendarItem.AddSelection(CalendarDayButton b) at System.Windows.Controls.Primitives.CalendarItem.Cell_MouseLeftButtonUp(Object sender, MouseButtonEventArgs e) at System.Windows.Controls.Primitives.CalendarDayButton.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

1
What exactly is throwing the exception? What does the stack trace look like? Is any of your code running when the date is selected?Jon Skeet
Am not able to get the stack trace or disassembly of this error. This is not hitting any piece of code. In debug mode its taking me to a new tab in visualstudio "No Source Available"Suja Shyam
I have edited to include the image of the exception.Suja Shyam
Are you firing some kind of events after selecting a date?josemiguel.torres
In the cs file I have given nothing in the selectedDateChanged event private void calTenderDate_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) { string str = "Test"; }Suja Shyam

1 Answers

0
votes

Whats happening when you change this date? I mean is there anything handling this event? It seems you are trying to change a list (maybe the datasource from a listbox?) from an other thread than the UI thread.