Intersoft ClientUI 8 > ClientUI Fundamentals > Navigation Overview > Navigation How-to Topics > How-to: Get the Navigation Frame that Hosts a Page |
This example shows how to get the UXFrame instance that hosts the specified page or UIElement.
Often times, you need to get the UXFrame instance that hosts your page or a particular UIElement that existed in the page to access particular information of the frame or perform a service of the frame through API calls such as performing navigation operation.
The following code example shows how to get the navigation host of a UXPage.
C# |
Copy Code
|
---|---|
public partial class CustomerPage : UXPage { private void UXButton1_Click(object sender, RoutedEventArgs e) { // Get the navigator host of this page INavigate navigator = this.GetNavigator(); // Call the Navigate method of the navigator host // to navigate to Home page navigator.Navigate(new Uri("/Home", UriKind.Relative)); } } |
UXFrame also provides GetFrameHost static method that allows you to get the UXFrame instance of the given UIElement, which is shown in the following code example.
C# |
Copy Code
|
---|---|
private void UXButton1_Click(object sender, RoutedEventArgs e) { // Get the UXFrame that hosts the panel UXFrame frame = UXFrame.GetFrameHost(this.LayoutRoot); if (frame != null) { // Call the Navigate method navigator.Navigate(new Uri("/Home", UriKind.Relative)); } } |