Xamarin.Forms Guides | Samples

Xamarin.Forms.VisualElement.Navigation Property

Gets the context aware navigation interface for the element.

Syntax

public INavigation Navigation { get; }

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 VisualElement.Activated event.

C# Example

  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);
    }
  }

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0