Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to provide a custom INavigationViewLocator so other OIC c… #32

Merged
merged 2 commits into from
Jun 9, 2024

Conversation

danielmeza
Copy link
Contributor

Add ability to provide a custom INavigationViewLocator so other OIC containers can be used to create views.

Now the UseShell extension method can receive a Func factory function to provide a custom view locator.

This is useful in cases such as custom view locators from the target project.

Also a DelegateNavigationViewLocator was created to simplify the INavigationViewLocator implementation.

How to used?

Imagine we have implemented a custom view locator using MSDI package or CommunityToolkit.Mvvm.DependencyInjection,
Then we can just replace the default INavigationViewLocator like this.

      app.UseShell(()=>  new CustomNavigationViewLocator());

or for CummunityToolkit.Mvvm.DependencyInjection

      app.UseShell(()=> Ioc.Default.GetRequriedService<INavigationViewLocator>());

or for delegate view creation

      app.UseShell((node)=> Activator.CreateInstance(node.Page));

@OmidID OmidID merged commit 44f6ae7 into AvaloniaInside:main Jun 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants