Screen Transitions with View Tree
ThisIn pagethis usespage, you use the basic Views prepared in the previous page to buildcompose two screen-level Views —Views, MainView and DetailView —DetailView, and arrangesarrange them as siblings onin the View Tree.
The central themethemes youof willthis learnpage here isare how to assemble a single screen in the View Definition Editor and why a sibling relationship onin the View Tree is suited tofor mutually exclusive screen switching. You will also assignconfigure Jump To View toon buttonsa button and verify in the Player that MainView and DetailView switch without overlapping. This page is the core part for masteringlearning the fundamentalsbasics of the View Editor — defining screen-level Views inand theusing sibling View Editor and navigating between sibling Views.transitions.
Creating MainView
In this section,Here, you definebundle the background, the common header, and the main content into a View that represents the entire main screenscreen. byProceed combiningwhile the background, a shared header, and the main content. As you work through the steps, keep in mindunderstanding that the View Definition Editor is "the place where youto assemble a screen-level Views.View."
- In Solution Explorer, select the Solution folder and select Add > New Item from the context menu.
- In the New Item dialog, select View and name it MainView.
- Double-click the created MainView to open the View Definition Editor.
- Add the following elements to the left pane of the View Definition Editor:
Background_ViewBackgroundHeaderViewHeaderMainContent_ViewMainContent
MainView is a View that consolidatesbundles the background, the sharedcommon header, and the main-contents of the main screen content into a single screen state. NoteIt is also important that HeaderViewyou isreuse reused hereHeader as an existing View — this demonstratesteaches the conceptidea of extracting commonshared components intoas separate Views forand reuse.reusing them.
Creating DetailView
Next, you define a View that represents the entire detail screen. As with MainView, you use the background and header are reused as shared components;components, and only the content portion differs. This approach lets multiple screens share the same visual framework while only switching only their content.
- In Solution Explorer, select the Solution folder and select Add > New Item from the context menu.
- In the New Item dialog, select View and name it DetailView.
- Double-click the created DetailView to open the View Definition Editor.
- Add the following elements to the left pane of the View Definition Editor:
Background_ViewBackgroundHeaderViewHeaderDetailContent_ViewDetailContent
DetailView is also an independent View that represents anthe entire screen. Because it shares the same background and header as MainView and differs only inreplaces the content, you can easily switch betweenperform screen-level Viewsswitching onin the View Tree later.
Building theConfiguring MainViewTree
HereHere, you place MainView and DetailView ontoin the View Tree. The most important point is to arrangemake themthe astwo siblings.a sibling relationship. A sibling relationship is suited tofor switching between independent screen states.
- In Solution Explorer, select the Solution folder and select Add > New Item from the context menu.
- In the New Item dialog, select ViewTree and name it MainViewTree.
- Double-click the created MainViewTree to open the View Tree panel.
- Drag and drop MainView onto the View Tree panel to add it as a top-level View State.
Similarly,In the same way, drag and drop DetailView into the empty area below MainView to add it as a top-level View State.
Verifying the Sibling Relationship onin the View Tree
- MainView and DetailView are at the same
hierarchyhierarchical level (DetailView is not a child of MainView). TheseThe twoViewsare targetsfortomutuallyswitchexclusivebetweenswitching.exclusively.
If you drop DetailView onto the body of MainView,MainView ithere, becomes a child, which may inadvertentlyyou create a parent-child relationship, and the resulting structure may unintentionally behave close to simultaneous display. Because you want to switch between the entire screens in this tutorial,time, always drop DetailView into the empty area below MainView to arrangeplace them as siblings.
Configuring Transitions Between Views
From this point,here, you setmake upit Jumppossible Toto View so that you can navigatemove between the sibling Views defined onin the View Tree.Tree Noteusing Jump To View. The key point is that theyou transition target must bespecify the completed screen-level View,View as the transition target, not a content View.
- Double-click the MainContent scene to open the Scene Editor.
- In the Scene Tree, select OpenDetailButton.
- Drag and drop a Jump To View behavior onto Action in the Extra Scene Tree.
- Select the added Jump To View behavior and configure the following properties in the Properties panel:
Property Category Item Value General Name JumpToDetailView Asset View DetailView
The reason youYou specify DetailView rather(a thanComposite DetailContent_ViewView that includes the background and header) — not DetailContent (a Scene with IsView=true on its own) — as the transition target is thatbecause you want to switch at the screen level, including the background and header. This is where theThe flow connects:of thetreating compositea Composite View you builtcreated in the View Definition Editor is used as a state onin the View Tree.Tree connects here.
ApplyIn the same procedureway, to set upconfigure the return transition from DetailView to MainView. This completes the round-trip switching between sibling Views.
- Double-click the DetailContent scene to open the Scene Editor.
- In the Scene Tree, select BackButton.
- Drag and drop a Jump To View behavior onto Action in the Extra Scene Tree.
- Select the added Jump To View behavior and configure the following properties in the Properties panel:
Property Category Item Value General Name JumpToMainView Asset View MainView
Verifying in the Player
HereHere, you verify not onlyjust the switching between MainView and DetailViewDetailView, but also whether the Background's clear setting on the Backgroundconfiguration is working correctly.effective. Even when the transition itself succeeds, aif the previous screen mayremains remain visible; in such cases,visible, the cause is more often on the Background side ratherthan thanin the View Tree.
- Save the solution and launch the Player.
- Verify that MainView
appearsis displayed immediately after launch.
- Verify that MainView
- Click the Open Detail button.
- Verify that the screen switches to DetailView.
- Verify that the screen switches to DetailView.
- Click the Back button.
- Verify that the screen returns to MainView.
In this page, you builtcomposed MainView and DetailView as screen-level Views in the View Definition Editor and arrangedplaced them as siblings onin the View Tree. You also implemented basic screen switching between sibling Views by using Jump To View. In the next page, you willlearn learna different use case — a parent-child relationship — a structure with a different purpose — that switches only a local state while keepingpreserving the shared display intact.display.