public static class NavigationTarget Creates navigation targets and states who owns their content.
Methods
Borrow
public static INavigationTarget<T> Borrow<T>(T content) where T : class Presents content owned by the caller or a container. The navigator never disposes or forgets it, and leaves the regions it owns alone.
Create
public static INavigationTarget<T> Create<T>(Func<IServiceProvider, T> factory) where T : class Creates owned content when the transition prepares. The factory receives the entry's service provider (NavigationEntry.Services) to resolve constructor dependencies, which stay container-owned; it must construct the content itself with new. To pass the content its entry's NavigationEntryContext, use NavigationTarget.Create.
Create
public static INavigationTarget<T> Create<T>(Func<IServiceProvider, NavigationEntryContext, T> factory) where T : class Creates owned content like NavigationTarget.Create; the factory also receives the new entry's NavigationEntryContext to pass to the content's constructor. The context belongs to the entry being prepared: its NavigationEntryContext.State is NavigationEntryState.Pending until the transition commits.
Create
public static INavigationTarget<T> Create<T, TInput>(Func<IServiceProvider, T> factory, TInput input) where T : class, INavigationInput<TInput> Creates owned content like NavigationTarget.Create and passes it input: INavigationInitialize.InitializeAsync runs instead of INavigationInitialize.InitializeAsync, and INavigationArrived.OnArrivedAsync instead of INavigationArrived.OnArrivedAsync, for the hooks the content implements.
Create
public static INavigationTarget<T> Create<T, TInput>(Func<IServiceProvider, NavigationEntryContext, T> factory, TInput input) where T : class, INavigationInput<TInput> Creates owned content like NavigationTarget.Create and passes it input, like NavigationTarget.Create.
Create
public static INavigationTarget<T> Create<T>() where T : class Constructs owned content of type T when the transition prepares, with ActivatorUtilities.CreateInstance. Constructor parameters are resolved from the entry's service provider (NavigationEntry.Services) and stay container-owned; a NavigationEntryContext parameter receives the new entry's context. T itself is never resolved from the container. Mark a constructor with ActivatorUtilitiesConstructorAttribute to choose it.
Type parameters
TThe content type to construct.
Create
public static INavigationTarget<T> Create<T, TInput>(TInput input) where T : class, INavigationInput<TInput> Constructs owned content like NavigationTarget.Create and passes it input, like NavigationTarget.Create: through INavigationInitialize.InitializeAsync and INavigationArrived.OnArrivedAsync, for the hooks the content implements.
Type parameters
TThe content type to construct.
TInputThe input type.
Parameters
inputThe input passed to the content's typed initialize and arrival hooks.
Own
public static INavigationTarget<T> Own<T>(T content) where T : class Hands content constructed with new over to the navigator, which forgets and disposes it when its entry retires. An instance can be owned only once; content resolved from a container must be borrowed instead.
Share
public static INavigationTarget<T> Share<T>(T content) where T : class Holds content together with the other entries of the navigator that hold it, and forgets and disposes it when the last of them retires. Pass a new instance, or the content of a live entry of this navigator created with NavigationTarget.Own, a Create target or NavigationTarget.Share; for example, hand the current page over to the next entry with ReplaceAsync(NavigationTarget.Share(current)), which disposes nothing.
Remarks
The request throws InvalidOperationException when the content was owned and fully released, is held by another navigator, or owns navigation regions; shared content can't own regions, and RunicNavigator.CreateRegion with shared content as owner throws. A shared target can't be an initial target: start the region with NavigationTarget.Own or a Create target, then share that content.
Each entry is its own entry: INavigationInitialize runs for each, and content that keeps the NavigationEntryContext it was constructed with still has its first entry's context after that entry retired; take the context in INavigationInitialize.InitializeAsync or INavigationArrived.OnArrivedAsync instead. The entry scope of created content (RunicNavigatorOptions.CreateEntryScopes) lives until the content is disposed. Don't also NavigationTarget.Borrow shared content: the borrowing entry can outlive its disposal.