Closed Gh0s7 closed 8 years ago
Sub-classing anything should have a constructor like:
class MyClass: MyBase {
public MyClass() : base() { }
}
I'm sorry but I don't know why you're talking about sub-classing since Category
doesn't extend anything.
By the way I've added that kind of constructor and now both Name
and Entries
are null after navigation, as if instead of passing the object instance as reference it calls the empty constructor everytime the page loads.
So I removed the empty constructor from both Category
and Entry
to see what happens, and it leads to
System.Exception: Your parameter must be serializable. If it isn't, then use SessionState.
Next step was to add DataContract
to both Category
and Entry
to make them serializable, but now it won't even navigate from the hamburger and I really have no clue on what's going on :(
EDIT:
To make things easier, since I think I'm having issues explaining my problem, here's a quick stripped-out version of my project: Repro.zip on Dropbox
I'm adding dynamically buttons to the
MyHamburger
insideShell.xaml
, based on user's input. Basically the user inserts the name of a category and hits the add button, having the new category shown on the hamburger. This new button should navigate to the detail page, unfortunately theOnNavigatedToAsync
receives a new and dempty category as parameter and I don't understant why.Here's some code:
Shell.xaml - addNewCategory method
CategoryPageViewModel
Category model
What am I doing wrong?
EDIT:
For some reasons I tried removing the empty constructor and it now works, is this the correct behavior?
EDIT 2:
After removing that constructor it works, but the other constructor gets called a huge number of times during navigation, and everytime it resets the
Entries
list which will always be empty when I load the page. I feel like I'm missing the reason why the ctor is called so many times during navigation.