Getting Error when Set the value to DefaultViewModel in async method
async void SpotlightVideo_FadeIn_Completed(object sender, object e)
{
this.DefaultViewModel["SpotlightImageSource"] = (await ExtensionMethods.GetSingleImage(1, SpotlightVideo.Image)).Source;
Spotlight_Videos s = this.DefaultViewModel["SpotlightVideos"] as Spotlight_Videos;
//s.Discription = SpotlightVideo.Discription;
//s.Image = SpotlightVideo.Image;
//s.Video_Id = SpotlightVideo.Video_Id;
//s.Video_Name = SpotlightVideo.Video_Name;
//s.VideoPath = SpotlightVideo.VideoPath;
this.DefaultViewModel["SpotlightVideos"] = SpotlightVideo;
//s = SpotlightVideo;
SpotlightVideo_FadeOut.Begin();
}
the first line in the mehtod runs fine DefaultViewModel["SpotlightImageSource"]
but this.DefaultViewModel["SpotlightVideos"] = SpotlightVideo;
gives me error of:
"Value does not fall within the expected range."
but when I set values to individual properties it runs fine with no error.
When I pass whole object to s variable it runs wioth no error but didnt give result as expected.
I debuged the code and basicallty the error is generating from ObservableDictionary.cs
private void InvokeMapChanged(CollectionChange change, string key)
{
var eventHandler = MapChanged;
if (eventHandler != null)
{
eventHandler(this, new ObservableDictionaryChangedEventArgs(change, key));
}
}
The error line is:
eventHandler(this, new ObservableDictionaryChangedEventArgs(change, key));
Please Help me out.