0

I'm trying to pass an ObservableCollection from one Frame to the next in a Windows universal app and this is how my OnNavigatedTo looks like:

protected async override void OnNavigatedTo(NavigationEventArgs e)
{
     var temp = e.Parameter as ObservableCollection<Information>;
     foreach (var item in temp)
     {
          //Do something here
     }
}

Problem is everytime this gets called, temp takes NULL value I get an NullReferenceException. Any ideas?

i_ll_be_back
  • 307
  • 1
  • 13
  • @Plutonix No. When I put a breakpoint at the e.Parameter it shows me that it contains the entire ObservableCollection – i_ll_be_back Sep 11 '16 at 18:39
  • what is e.Parameter.getType() ? – DarkSquirrel42 Sep 11 '16 at 18:45
  • If `e.Parameter` is not of the type `ObservableCollection`, then temp will be assigned `null`. – hatchet - done with SOverflow Sep 11 '16 at 18:49
  • Do a direct cast instead of using `as` operator like `(ObservableCollection)e.Parameter` which will fail if the type doesn't match and throw exception – Rahul Sep 11 '16 at 18:53
  • You were right..For some very strange reason it has taken my obervablecollectin and transformed it into a System.String...I'm using Template10 for windows universal apps from githab https://github.com/Windows-XAML/Template10/tree/master/Template10%20(Library) Anyone has used it before??I'm passing the parameter through HamburgerButtonInfo.PageParameter @DarkSquirrel42 – i_ll_be_back Sep 11 '16 at 21:09
  • Any ideas ?@hatchet – i_ll_be_back Sep 11 '16 at 21:12
  • Any ideas? @Rahul – i_ll_be_back Sep 11 '16 at 21:12
  • @i_ll_be_back ... SO does not work this way... if you still have a specific question, please open a new, more precise question, and try to give the code for a minimal working example to reproduce your problem – DarkSquirrel42 Sep 12 '16 at 09:15

0 Answers0