Property AlreadyNavigatedTo
AlreadyNavigatedTo
Gets a value indicating whether the view was already navigated to during the last navigation.
Declaration
public bool AlreadyNavigatedTo { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The value of this property will be true if the view model had already been navigated to during a previous navigation but had not been navigated away from. Some situations where this can happen are:
- The new route is the same as the last navigated route.
- Only route options changed but the rest of the route is the same.
- A refresh of the current route was requested (in which case NavigationType will be set to Refresh).
- The view model is a common parent for this route and the last navigated route but nested child navigations changed.
Any logic that depends on being paired with navigations away from the view model (i.e. adding/removing event handlers) should be conditional on this property being false, otherwise the navigated to logic may be executed more times than the navigated away logic. Additionally, the view model will not be transitioned to a "navigated to" state if it cancels/reroutes the navigation, so logic that should be paired with navigations away from the view model should not be executed if the view model cancels the navigation - a subsequent navigated away from call will not occur if the navigation is cancelled.