code-samples icon indicating copy to clipboard operation
code-samples copied to clipboard

HamburgerMenuApp.V4 view from MenuItem will be constructed twice

Open ali50m opened this issue 2 years ago • 1 comments

After adding the following code to HomeView.Xaml.cs in HamburgerMenuApp.Core and make HamburgerMenuApp.V4 output debug message to console, then I found the "HomeView ctor..." message will pop up twice even I just click the Home menuItem once. I can`t see this issue in other V1~V3 samples, seems like the menuItem views is singleton in these projects.

=================================================

public HomeView() { InitializeComponent(); Console.WriteLine($@"{GetType().Name} ctor..."); }

~HomeView() => Console.WriteLine($@"{GetType().Name} dtor...");

ali50m avatar Aug 04 '21 13:08 ali50m

screen-cap

I attached the screen capture here.. as you may see, I clicked the Home menu Item 4 times , but "HomeView ctor..." was printed 6 times. Since it`s not a 100% happened, so I clicked several times for better demonstrating this issue.

ali50m avatar Aug 04 '21 14:08 ali50m