Open KWodarczyk opened 2 weeks ago
modify to: services.AddTransient<ISomeUtils, SomeUtils>();
@lhLife .AddTransient does fix the issue but, it's not ideal as it forces developer to use Transient, even if they want a Singleton, I would treat this as temporary work around. I also think that this should be documented in Uno docs for example somewhere on this page https://platform.uno/docs/articles/external/uno.extensions/doc/Reference/Navigation/Navigator.html
It cannot be a singleton, it can only expose INavigatorFactory or INavigator wrapper。 The entire program is a tree like structure that can be navigated anywhere。 demo:Not real code Where do you think INavigator should navigate from
<Page>
<Frame Navigator="FrameNavigator">
<Page2>
<Panel1 Navigator="PanelVisiblityNavigator">
<Page3/>
</Panel1>
<Panel2 Navigator="PanelVisiblityNavigator">
<Page4/>
</Panel2>
</Page2>
</Frame>
</Page>
The setting of the region is good, but INavigator needs a wrapper class to solve its complexity.
It cannot be a singleton, it can only expose INavigatorFactory or INavigator wrapper。 The entire program is a tree like structure that can be navigated anywhere。 demo:Not real code Where do you think INavigator should navigate from
<Page> <Frame Navigator="FrameNavigator"> <Page2> <Panel1 Navigator="PanelVisiblityNavigator"> <Page3/> </Panel1> <Panel2 Navigator="PanelVisiblityNavigator"> <Page4/> </Panel2> </Page2> </Frame> </Page>
Sorry I don't follow, you have two regions with same name ?
Each page is a separate page. When you navigate through the Model on Page 4, there are PanelVisilityNavigator and FrameNavigator at the top level, and multiple options will appear. Therefore, they can only be Transient (PanelVisilityNavigator)
Current behavior
I have SomeUtils class that takes UnoAppNavigation2.zip in INavigator as ctor parameter, at creation the parameter is null
App.xaml.cs
MainPage.xaml cs getting ISomeUtils class instance
SomeUtils class
Expected behavior
INavigator should not be null when injected to a SomeUtils class
How to reproduce it (as minimally and precisely as possible)
Build and run project attached, put a brakepoint in SomeUtlis class ctor. INavigator parameter will be null.
Workaround
No response
Works on UWP/WinUI
None
Environment
Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
NuGet package version(s)
No response
Affected platforms
Windows (WinAppSDK)
IDE
Visual Studio 2022
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response