NavigationEventArgs
NavigationEventArgs
NavigationEventArgs
NavigationEventArgs
Class
Definition
Provides data for navigation methods and event handlers that cannot cancel the navigation request.
public : sealed class NavigationEventArgs : INavigationEventArgs, INavigationEventArgs2public sealed class NavigationEventArgs : INavigationEventArgs, INavigationEventArgs2Public NotInheritable Class NavigationEventArgs Implements INavigationEventArgs, INavigationEventArgs2// This API is not available in Javascript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Examples
The following example code demonstrates the use of this type. For the complete code listing, see the XAML WebView control sample.
void SDKSample::WebViewControl::Scenario1::NavigateButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
ProgressRing1->IsActive = true;
// Provide an indication as to where we are trying to navigate to
String^ str = "Navigating to: {0}" + Address->Text;
rootPage->NotifyUser(str, NotifyType::StatusMessage);
// Hook the LoadCompleted event for the WebView to know when the URL is fully loaded
WebView1->LoadCompleted += ref new LoadCompletedEventHandler(this, &Scenario1::WebView1_LoadCompleted);
// Attempt to navigate to the specified URL. Notice that a malformed URL will raise a FormatException
// which we catch and let the user know that the URL is bad and to enter a new well-formed one.
try
{
Uri^ targetUri = ref new Uri(Address->Text);
WebView1->Navigate(targetUri);
}
catch (FailureException^ myE)
{
// Bad address
String^ str = "Address is invalid, try again. Details --> {0}" + myE->Message;
rootPage->NotifyUser(str, NotifyType::ErrorMessage);
}
}
void SDKSample::WebViewControl::Scenario1::WebView1_LoadCompleted(Platform::Object^ sender, Windows::UI::Xaml::Navigation::NavigationEventArgs^ e)
{
WebView1->Visibility = Windows::UI::Xaml::Visibility::Visible;
BlockingRect->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
ProgressRing1->IsActive = false;
// Tell the user that the page has loaded
rootPage->NotifyUser("Page loaded", NotifyType::StatusMessage);
}
void SDKSample::WebViewControl::Scenario1::Address_KeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if (e->Key == Windows::System::VirtualKey::Enter)
{
NavigateButton_Click(this, ref new RoutedEventArgs());
}
}
private void NavigateButton_Click(object sender, RoutedEventArgs e)
{
ProgressRing1.IsActive = true;
// Provide an indication as to where we are trying to navigate to
rootPage.NotifyUser(String.Format("Navigating to: {0}", Address.Text), NotifyType.StatusMessage);
// Hook the LoadCompleted event for the WebView to know when the URL is fully loaded
WebView1.LoadCompleted += new Windows.UI.Xaml.Navigation.LoadCompletedEventHandler(WebView1_LoadCompleted);
// Attempt to navigate to the specified URL. Notice that a malformed URL will raise a FormatException
// which we catch and let the user know that the URL is bad and to enter a new well-formed one.
try
{
Uri targetUri = new Uri(Address.Text);
WebView1.Navigate(targetUri);
}
catch (FormatException myE)
{
// Bad address
rootPage.NotifyUser(String.Format("Address is invalid, try again. Details --> {0}", myE.Message), NotifyType.ErrorMessage);
}
}
void WebView1_LoadCompleted(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
WebView1.Visibility = Windows.UI.Xaml.Visibility.Visible;
BlockingRect.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
ProgressRing1.IsActive = false;
// Tell the user that the page has loaded
rootPage.NotifyUser("Page loaded", NotifyType.StatusMessage);
}
void Address_KeyUp(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Enter)
{
NavigateButton_Click(this, new RoutedEventArgs());
}
}
Private Sub NavigateButton_Click(sender As Object, e As RoutedEventArgs)
ProgressRing1.IsActive = True
' Provide an indication as to where we are trying to navigate to
rootPage.NotifyUser(String.Format("Navigating to: {0}", Address.Text), NotifyType.StatusMessage)
' Hook the LoadCompleted event for the WebView to know when the URL is fully loaded
AddHandler WebView1.LoadCompleted, AddressOf WebView1_LoadCompleted
' Attempt to navigate to the specified URL. Notice that a malformed URL will raise a FormatException
' which we catch and let the user know that the URL is bad and to enter a new well-formed one.
Try
Dim targetUri As New Uri(Address.Text)
WebView1.Navigate(targetUri)
Catch myE As FormatException
' Bad address
rootPage.NotifyUser(String.Format("Address is invalid, try again. Details --> {0}", myE.Message), NotifyType.ErrorMessage)
End Try
End Sub
Private Sub WebView1_LoadCompleted(sender As Object, e As Windows.UI.Xaml.Navigation.NavigationEventArgs)
WebView1.Visibility = Windows.UI.Xaml.Visibility.Visible
BlockingRect.Visibility = Windows.UI.Xaml.Visibility.Collapsed
ProgressRing1.IsActive = False
' Tell the user that the page has loaded
rootPage.NotifyUser("Page loaded", NotifyType.StatusMessage)
End Sub
Private Sub Address_KeyUp(sender As Object, e As Object)
'If e.Key = Windows.System.VirtualKey.Enter Then
' NavigateButton_Click(Me, New RoutedEventArgs())
'End If
End Sub
Properties
Content Content Content Content
Gets the root node of the target page's content.
public : PlatForm::Object Content { get; }public object Content { get; }Public ReadOnly Property Content As object// This API is not available in Javascript.
- Value
- PlatForm::Object object object object
The root node of the target page's content.
NavigationMode NavigationMode NavigationMode NavigationMode
Gets a value that indicates the direction of movement during navigation
public : NavigationMode NavigationMode { get; }public NavigationMode NavigationMode { get; }Public ReadOnly Property NavigationMode As NavigationMode// This API is not available in Javascript.
A value of the enumeration.
NavigationTransitionInfo NavigationTransitionInfo NavigationTransitionInfo NavigationTransitionInfo
Gets a value that indicates the animated transition associated with the navigation.
public : NavigationTransitionInfo NavigationTransitionInfo { get; }public NavigationTransitionInfo NavigationTransitionInfo { get; }Public ReadOnly Property NavigationTransitionInfo As NavigationTransitionInfo// This API is not available in Javascript.
- Value
- NavigationTransitionInfo NavigationTransitionInfo NavigationTransitionInfo NavigationTransitionInfo
Info about the animated transition.
Parameter Parameter Parameter Parameter
Gets any "Parameter" object passed to the target page for the navigation.
public : PlatForm::Object Parameter { get; }public object Parameter { get; }Public ReadOnly Property Parameter As object// This API is not available in Javascript.
- Value
- PlatForm::Object object object object
An object that potentially passes parameters to the navigation target. May be null.
SourcePageType SourcePageType SourcePageType SourcePageType
Gets the data type of the source page.
public : TypeName SourcePageType { get; }public Type SourcePageType { get; }Public ReadOnly Property SourcePageType As Type// This API is not available in Javascript.
- Value
- TypeName Type Type Type
The data type of the source page, represented as namespace.type or simply type.
Remarks
When the navigation occurs as a result of the app being launched, the SourcePageType is equal to the typeof the page being navigated to.
Uri Uri Uri Uri
Gets the Uniform Resource Identifier (URI) of the target.
public : Uri Uri { get; set; }public Uri Uri { get; set; }Public ReadWrite Property Uri As Uri// This API is not available in Javascript.
- Value
- Uri Uri Uri Uri
A value that represents the Uniform Resource Identifier (URI).