In the OpenChildPage callback we need to open the child page passing the current value: we want to edit the value in entry control.
Let's change the child page by adding a state and a props class as shown in the following code:
Now the ChildPageComponent has a state and a props: the latter will hold the initial value and a callback action to call when the user click the back button.
Finally, call the child page setting its props properties:
Handle notifications from pages when appearing or disappearing
In MauiReactor components are deactivated when are no more referenced by any other parent components: when this happens MauiReactor calls the OnWillUnmount method to let the developer do extra finalization stuff.
Makes exceptions the case when the component is the root of the page. For performance reasons when the page disappears, MauiReactor doesn't traverse for the last time the visual tree so it doesn't call the OnWillUnmount on the root component.
Maybe you need to do some work when the page is disappearing; the following code shows how you handle the disappearing event from both the calling and the called page.
publicclassFirstPage:Component{protectedoverridevoidOnWillUnmount() { //this won't be called because is the root component of the pageDebug.WriteLine("OnWillUnmount FirstPage"); }protectedoverridevoidOnMounted() {Debug.WriteLine("OnMounted FirstPage"); }publicoverrideVisualNodeRender() {returnnewContentPage() {newVStack() {newLabel("First!"),newButton("Next") .OnClicked(async () => { var secondPage =awaitNavigation?.PushAsync<SecondPage>();secondPage.Disappearing+=(s,e)=>Debug.WriteLine("Disappearing SecondPage"); }) } .Spacing(20) .HCenter() .VCenter() }.Title("First"); }}publicclassSecondPage:Component{protectedoverridevoidOnWillUnmount() { //this won't be called because is the root component of the pageDebug.WriteLine("OnWillUnmount SecondPage"); }protectedoverridevoidOnMounted() {Debug.WriteLine("OnMounted SecondPage"); }publicoverrideVisualNodeRender() {returnnewContentPage() {newVStack() {newLabel("Second!"),newButton("Back") .OnClicked(() =>Navigation?.PopAsync()) } .Spacing(20) .HCenter() .VCenter() } .Title("Second") .OnDisappearing(()=>Debug.WriteLine("Disappearing SecondPage from SecondPage")); }}publicclassApp:Component{publicoverrideVisualNodeRender() {returnnewNavigationPage() {newFirstPage() }.Set(MauiControls.NavigationPage.BarTextColorProperty,Colors.White); }}c