canton7 / Stylet

A very lightweight but powerful ViewModel-First MVVM framework for WPF for .NET Framework and .NET Core, inspired by Caliburn.Micro.
MIT License
981 stars 143 forks source link

OnInitialActivate Invalid #219

Closed wf-soft closed 3 years ago

wf-soft commented 3 years ago

In the following case, screen is not the main window, but through the injected conductor, oninitialactivate will not be triggered

` public class MainViewModel : Screen { [Inject] public Test2ViewModel Test2VM { get; set; } }

public class Test2ViewModel : Conductor.Collection.OneActive { protected override void OnViewLoaded() { base.OnViewLoaded(); Items.Add(Helper.Ioc.Get()); Items.Add(Helper.Ioc.Get()); Items.Add(Helper.Ioc.Get()); Items[0].DisplayName = "0"; Items[1].DisplayName = "1"; Items[2].DisplayName = "2"; } }

public class TestViewModel : Conductor.Collection.OneActive { protected override void OnInitialActivate() { base.OnInitialActivate(); Debug.WriteLine("我被激活了"); } } `

wf-soft commented 3 years ago

@canton7 Is this normal?