You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
No response
Describe the solution you'd like
The generated ConfigureServices() in App.xaml.cs can be misleading, since it registers pages as services. When NavigationService.NavigateTo() is called, a type is passed to _frame.Navigate() instead of an instance. As I have seen WinUI’s API does not support passing instance to the Frame.Navigate() method. (it also makes parametrized constructors prohibited)
I found a solution to enable Frame.Navigate() to instantiate a page via an IServiceProvider interface. When Frame.Navigate() is called, it retrieves an IXamlType from the App, IXamlType.ActivateInstance() method is responsible for creating the instance from a type. The ActivateInstance() method can be redirected, and I created a sample app that shows how this redirection is implemented.
I think it would be great that the App.DI.cs could be included in the TemplateStudio’s source generator.
Is your feature request related to a problem? Please describe.
No response
Describe the solution you'd like
The generated
ConfigureServices()
inApp.xaml.cs
can be misleading, since it registers pages as services. WhenNavigationService.NavigateTo()
is called, a type is passed to_frame.Navigate()
instead of an instance. As I have seen WinUI’s API does not support passing instance to theFrame.Navigate()
method. (it also makes parametrized constructors prohibited)I found a solution to enable
Frame.Navigate()
to instantiate a page via anIServiceProvider
interface. WhenFrame.Navigate()
is called, it retrieves anIXamlType
from theApp
,IXamlType.ActivateInstance()
method is responsible for creating the instance from a type. TheActivateInstance()
method can be redirected, and I created a sample app that shows how this redirection is implemented.I think it would be great that the
App.DI.cs
could be included in the TemplateStudio’s source generator.Describe alternatives you've considered
No response
Additional context
Here is my example app.
Applies to the following platforms:
The text was updated successfully, but these errors were encountered: