This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
public:
bool Navigate(Uri ^ source, System::Object ^ navigationState, bool sandboxExternalContent);
public bool Navigate (Uri source, object navigationState, bool sandboxExternalContent);
member this.Navigate : Uri * obj * bool -> bool
Public Function Navigate (source As Uri, navigationState As Object, sandboxExternalContent As Boolean) As Boolean
Parameters
Download content into a partial trust security sandbox (with the default Internet zone set of permissions, if
true
. The default is
false
.
Returns
Remarks
This method is only for standalone applications and Extensible Application Markup Language (XAML) content.
This method exhibits the same behavior as
NavigationService.Navigate
, and extends it by ensuring that the content that is being downloaded is placed into a partial trust security sandbox (with the default Internet zone set of permissions - see
WPF Partial Trust Security
).
public:
bool Navigate(Uri ^ source, System::Object ^ navigationState);
public bool Navigate (Uri source, object navigationState);
member this.Navigate : Uri * obj -> bool
Public Function Navigate (source As Uri, navigationState As Object) As Boolean
Parameters
Examples
The following example demonstrates navigating to a URI and passing navigation state.
void goButton_Click(object sender, RoutedEventArgs e)
this.NavigationService.Navigate(new Uri(this.addressTextBox.Text), DateTime.Now);
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
DateTime requestDateTime = (DateTime)e.ExtraData;
string msg = string.Format("Request started {0}\nRequest completed {1}", requestDateTime, DateTime.Now);
MessageBox.Show(msg);
Private Sub goButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.NavigationService.Navigate(New Uri(Me.addressTextBox.Text), Date.Now)
End Sub
Private Sub NavigationService_LoadCompleted(ByVal sender As Object, ByVal e As NavigationEventArgs)
Dim requestDateTime As Date = CDate(e.ExtraData)
Dim msg As String = String.Format("Request started {0}" & vbLf & "Request completed {1}", requestDateTime, Date.Now)
MessageBox.Show(msg)
End Sub
Remarks
Since navigations are asynchronous, it is possible for multiple navigations to be in progress at the same time. For example, if there are two child frames on a single page, both frames could be navigating. In this case, the various navigation events that are raised by
NavigationService
may be raised multiple times, one for each piece of content that is being navigated to, and not necessarily in order that the navigations were requested. Consequently, if a particular navigation request needs to process data that is specific to the individual request, it cannot use data that is available to all navigation requests. Instead, you can use
navigationState
to pass data for navigation processing that is specific to one navigation request.
The following event arguments provide access to navigation state:
ExtraData
(passed to the
Navigating
event).
ExtraData
(passed to the
Navigated
,
NavigationStopped
,
LoadCompleted
event handlers).
bool Navigate(Uri ^ source);
public bool Navigate (Uri source);
member this.Navigate : Uri -> bool
Public Function Navigate (source As Uri) As Boolean
Parameters
The following example shows how to navigate to a URI.
void goButton_Click(object sender, RoutedEventArgs e)
this.NavigationService.Navigate(new Uri(this.addressTextBox.Text));
Private Sub goButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.NavigationService.Navigate(New Uri(Me.addressTextBox.Text))
End Sub
Remarks
The value of
source
can be a Web URL or a valid pack URI (see
Pack URIs in WPF
).
Navigate
will navigate to the URI specified by
source
if the following conditions are true:
The
Navigating
event is not cancelled.
A web request (see
Navigating
) can be created.
If
source
is
null
, the existing content (
Content
) is cleared.
When downloading Web content, you may receive a Web exception (for example, 404: File Not Found). You can handle such exceptions from
NavigationFailed
.
You can use
Navigate
to navigate to a content fragment. If the content identified by the URI is the current content, it is not downloaded again.
bool Navigate(System::Object ^ root);
public bool Navigate (object root);
member this.Navigate : obj -> bool
Public Function Navigate (root As Object) As Boolean
Parameters
Examples
The following example shows how to navigate to a
Page
object containing the source content tree.
void goObjectButton_Click(object sender, RoutedEventArgs e)
this.NavigationService.Navigate(new ContentPage());
Private Sub goObjectButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.NavigationService.Navigate(New ContentPage())
End Sub
Remarks
Navigate
will navigate to the
Object
specified by
root
if the following conditions are true:
The
Navigating
event is not cancelled.
A web request (see
Navigating
) can be created.
If
root
is
null
, the existing content (
Content
) is cleared.
When downloading Web content, you may receive a Web exception (for example, 404: File Not Found). You can handle such exceptions from
NavigationFailed
.
public:
bool Navigate(System::Object ^ root, System::Object ^ navigationState);
public bool Navigate (object root, object navigationState);
member this.Navigate : obj * obj -> bool
Public Function Navigate (root As Object, navigationState As Object) As Boolean
Parameters
Examples
The following example shows how to navigate to a
Page
object containing the source content, and passing navigation state.
void goButton_Click(object sender, RoutedEventArgs e)
this.NavigationService.Navigate(new ContentPage(), DateTime.Now);
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
DateTime requestDateTime = (DateTime)e.ExtraData;
string msg = string.Format("Request started {0}\nRequest completed {1}", requestDateTime, DateTime.Now);
MessageBox.Show(msg);
Private Sub goButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.NavigationService.Navigate(New ContentPage(), Date.Now)
End Sub
Private Sub NavigationService_LoadCompleted(ByVal sender As Object, ByVal e As NavigationEventArgs)
Dim requestDateTime As Date = CDate(e.ExtraData)
Dim msg As String = String.Format("Request started {0}" & vbLf & "Request completed {1}", requestDateTime, Date.Now)
MessageBox.Show(msg)
End Sub
Remarks
This method has the same behavior as
NavigationService.Navigate
, although an object is passed instead of a URI.