This example shows how to get the UXFrame instance which is the primary navigation frame in the specified page or UIElement.
Example
Description
In certain cases, your page may contain more than one navigation frame and you would like to get the the primary navigator in that particular page, perhaps to invoke a navigation process or obtain information about the primary navigator. You can get the primary navigator in a page or UIElement by calling the GetPrimaryNavigator static method of the UXFrame.
The frame determines the primary navigator through the following mechanism:
- If there is only one UXFrame instance in the specified source, then the matching instance will be automatically returned as the primary navigator.
- If there are multiple UXFrame instances in the specified source, the first matching frame with IsPrimaryNavigator property set to True will be returned.
- If there are multiple UXFrame instances in the specified source without matching frame, the function will return null (or Nothing in Visual Basic).
![]() |
It is best practice to consistently set the IsPrimaryNavigator to true in your navigation application, specifically for the root frame and navigation frames that integrates to browser's journal or uses child navigation. For more information about child navigation, see Advanced Features in ClientUI Navigation Framework. |
Code
The following code example shows how to get the primary navigator that existed in the root visual element.
C# | ![]() |
---|---|
private void DisplayErrorToNavigationFrame(ApplicationUnhandledExceptionEventArgs e) { // Get the primary UXFrame that existed in root visual UXFrame frame = UXFrame.GetPrimaryNavigator(this.RootVisual); if (frame != null) { // Navigate to the error page and pass along the event data frame.Navigate(new Uri("/Error", UriKind.Relative), e); } } |