microsoft / microsoft/microsoft-ui-xaml

Proposal: Expose a custom Page activator for Frame navigation

Open
#11,915 1 comment 3 reactions 0 assignees View on GitHub
area-Navigation feature proposal team-Controls
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Title

Expose a custom `Page` activator for `Frame` navigation

### Summary

Allow developers to customize how `Frame` creates a `Page` instance from a page Type, while preserving the existing navigation behavior as the default.

### Rationale

- `Frame.Navigate(Type)` does not provide a way for applications to control how a `Page` instance is created.
- This makes constructor injection difficult and often forces applications to use service locators or custom navigation layers.
- This makes clean MVVM architectures harder to implement, because view creation cannot be cleanly integrated with an application's composition and dependency injection model.
- A page activation hook would allow MVVM frameworks and application code to integrate with `Frame` while preserving the existing navigation model.

### Scope

| Capability | Priority |
| :---------- | :------- |
| Allow developers to customize `Page` activation performed by `Frame` | Must |
| Preserve the existing XAML activation behavior when no custom activator is provided | Must |
| Preserve existing navigation caching and back-stack semantics | Must |
| Support constructor injection and arbitrary application-defined activation strategies | Should |
| Integrate directly with a specific DI framework | Won't |

### Important Notes

A possible API could be:

```csharp
public interface IFramePageActivator
{
Page ActivatePage(Type pageType);
}

public IFramePageActivator? PageActivator { get; set; }
```

For example:

```csharp
frame.PageActivator = new ServiceProviderPageActivator(services);
frame.Navigate(typeof(SettingsPage));
```

The important part of this proposal is the extensibility point itself, not the exact API shape.

Ideally, the custom activator would only be invoked when Frame actually needs to create a new page instance, so existing caching behavior remains unchanged

### Open Questions

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by examining Frame.Navigate(Type), Page creation, and the existing navigation caching and back-stack behavior. Define an extensibility point for custom activation while preserving the current default activation path; done means custom activation works when a new Page is needed and existing navigation behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.