VisualElement.Navigation VisualElement.Navigation Property

Definition

Gets the context aware navigation interface for the element.

public Xamarin.Forms.INavigation Navigation { get; }
member this.Navigation : Xamarin.Forms.INavigation
Property Value

An INavigation that allows for navigation using the ancestral navigation implementor.

Remarks

Use the Navigation property to perform navigation from any element. If the element has not yet been added to a tree which contains a navigation implementor, the actions are queued up until it is.

The following example navigates to a new page created in the callback of a buttons Xamarin.Forms.VisualElement.Activated event.


  partial class NavigationTest {
    void BuildContent 
    {
      Button button = new Button {Text = "Tap to Navigate"};
      button.Activated += OnButtonActivated;
    }

    void OnButtonActivated (object sender, EventArgs args)
    {
      Button button = (Button) sender;
      Page newPage = new ContentPage {
        Content = new Label {Text = "Hello New Page"}
      };

      button.Navigation.Push (newPage);
    }
  }
              

Applies to