Hi,
Little question, i was trying to optimise a TabbedPage of 3 pages.
To make it more fluid i have moved the call of initializeComponents() from the constructor to an overide of OnAppearing().
It works corectly but i have a doubt if it's an acceptable practice or not ?
Thanks.
So except for this point their is, in theory, no problem with the usage of InitializeComponent() into OnAppearing() ?
Hard to say what will happen when you deviate from standard practices. In 15+ years of XAML based development I've never worked on a project where it was done. Personally, to me, that would be a hint.
Answers
The same instance of a page or control could appear many times. Like every time the app is put in background and brought forward again. No need to do all this work every time it appears if just once in the constructor is sufficient.
Thanks for your answer.
In my previous situation the constructor was called with the inialization of the tabbed page, so the 3 pages was created everytimes.
But only the first tab contains major informations, the two others contains secondary information and they will not be display very frequently, so this seem to be an acceptable compromise because she will be load again anyway if the user quit the tabbed page and open it again.
So except for this point their is, in theory, no problem with the usage of InitializeComponent() into OnAppearing() ?
Hard to say what will happen when you deviate from standard practices. In 15+ years of XAML based development I've never worked on a project where it was done. Personally, to me, that would be a hint.
Ok, i will see if we keep this way or back to a more standard method.
Thanks
Was thinking exactly the same thing.
Thanks for you answer.
Can someone add his experience ?
Yeah- I brought that up to. But the OP didn't seem to mind if that happened.
I think i will check for a way to maintain a good balance between loading time and reload of data with a more traditional use of initializeComponents();
Thanks for your answer
is there any flag to check IsInitiliazed or not? because in theory this is a good idea, especially having tabbed page or master detailpage in order to gain some start up time. I am using freshmvvm and using masterdetail page it preinitializes each pages on masterdeail load. if I do this, i gain around 2 secs but it seems that things are created again as others said and it crashes on UWP telling that there is already a child.
you can just do it as below. this will insure that it will be initialized only once
+1