Skip to content

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
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