Back to Class Reference home page
MVVMbasics.Services.INavigatorService
MVVMbasics.Services.NavigatorService
[MvvmService]
public class NavigatorService : INavigatorService
Service which provides page / window navigation functionality. Includes both "standard" navigation methods which navigate backwards as well as a View-/Viewmodel-Locator that stores mappings of View to Viewmodel and allows to directly navigate to a View that is associated with a given Viewmodel.
Method Summary | |
---|---|
void |
Register<T>(object view) where T : BaseViewmodel
Registers a mapping of Viewmodel to View. |
void |
RegisterAll(Assembly assembly = null)
Traverses all Views and registers all that provide a MvvmNavigationTarget attribute. |
void |
RegisterAll(string ns, Assembly assembly = null)
Traverses all Views that are located within a given namespace and registers all that provide a MvvmNavigationTarget attribute. |
object |
Retrieve<T>() where T : BaseViewmodel
Returns a View or throws an exception if no matching View has been registered. |
void |
NavigateTo<T>(params Parameter[] parameters) where T : BaseViewmodel
Retrieves a View and navigates to the corresponding page / window. |
void |
NavigateTo<T>(string key, object value) where T : BaseViewmodel
Retrieves a View and navigates to the corresponding page / window, passing one parameter. |
void |
NavigateTo<T>(ParameterList parameters) where T : BaseViewmodel
Retrieves a View and navigates to the corresponding page / window. |
void |
NavigateBack()
Navigates to the last View on the back stack. |
void |
SetBackParameters(params Parameter[] parameters)
Stores parameters to be passed to the previous View on the next backward navigation event. |
void |
SetBackParameters(string key, object value)
Stores one parameter to be passed to the previous View on the next backward navigation event. |
void |
SetBackParameters(ParameterList parameters)
Stores parameters to be passed to the previous View on the next backward navigation event. |
void |
ClearBackParameters()
Removes parameters which have been stored to be passed to the previous View on the next backward navigation event. |
bool |
CanGoBack()
Checks whether a backwards navigation is possible or not (the latter ist the case if the current View is the Application's main View). |
void |
RemoveBackEntry()
Removes the previously shown View from the back stack. |
void |
ClearBackStack()
Removes all entries from the back stack. |
Method Detail |
---|
public void Register<T>(object view) where T : BaseViewmodel
Registers a mapping of Viewmodel to View. Viewmodel must be supplied as Type object, View must be supplied as Uri object. The Viewmodel type must be a subtype of BaseViewmodel. Exceptions will be thrown if this type constraints is not fulfilled, or if a mapping with the specified Viewmodel type exists already.
public void RegisterAll(Assembly assembly = null)
Traverses all Views and registers all that provide a MvvmNavigationTarget attribute. An exception is thrown if one of the traversed Views references a Viewmodel type that has been registered already.
assembly
- Assembly to be scanned. If NULL, the calling assembly will be scanned.
public void RegisterAll(string ns, Assembly assembly = null)
Traverses all Views that are located within a given namespace inside a given assembly and registers all that provide a MvvmNavigationTarget attribute. An exception is thrown if one of the traversed Views references a Viewmodel type that has been registered already.
ns
- Namespace to be scanned. If ends with '.*', also sub-directories will be scanned. If NULL, the whole assembly will be scanned.
assembly
- Assembly to be scanned. If NULL, the calling assembly will be scanned.
public object Retrieve<T>() where T : BaseViewmodel
Returns a View or throws an exception if no matching View has been registered.
public void NavigateTo<T>(params Parameter[] parameters) where T : BaseViewmodel
Retrieves a View and navigates to the corresponding page / window.
public void NavigateTo<T>(string key, object value) where T : BaseViewmodel
Retrieves a View and navigates to the corresponding page / window, passing one parameter.
public void NavigateTo<T>(ParameterList parameters) where T : BaseViewmodel
Retrieves a View and navigates to the corresponding page / window.
public void NavigateBack()
Navigates to the last View on the back stack.
public void SetBackParameters(params Parameter[] parameters)
Stores parameters to be passed to the previous View on the next backward navigation event.
parameters
- Parameters to be stored for passing to the previos View.
public void SetBackParameters(string key, object value)
Stores one parameter to be passed to the previous View on the next backward navigation event.
key
- Key of the parameter to be stored for passing to the previos View.
value
- Value of the parameter to be stored for passing to the previos View.
public void SetBackParameters(ParameterList parameters)
Stores parameters to be passed to the previous View on the next backward navigation event.
parameters
- Parameters to be stored for passing to the previos View.
public void ClearBackParameters()
Removes parameters which have been stored to be passed to the previous View on the next backward navigation event.
public void ClearBackParameters()
Removes parameters which have been stored to be passed to the previous View on the next backward navigation event.
public bool CanGoBack()
Checks whether a backwards navigation is possible or not (the latter ist the case if the current View is the Application's main View).
TRUE if a backwards navigation is possible, FALSE otherwise.
public void RemoveBackEntry()
Removes the previously shown View from the back stack.
public void ClearBackStack()
Removes all entries from the back stack.