OnInitialActivate does not get called in "Child" Screen
uyaem opened this issue · comments
Description
OnInitialActivate does not get called in a "Child" Screen in controls if using <ContentControl>
to embed the child.
I cannot use any of the Conductor options on the parent, because there are potentially several "dynamic controls" on the page, as the application continues to grow.
Is this a bug, or by design, or am I doing something wrong?
To Reproduce
Below code snippet should suffice to reproduce the behaviour.
This is an extremely stripped down version of my scenario, and I hope it is complete enough. If not, I'll amend as needed.
/// ParentView.xaml
[...]
<ContentControl s:View.Model="{Binding DynamicControl}" [...] />
[...]
/// ParentViewModel.cs
public class ParentViewModel : Screen
{
private Func<ChildViewModel> createChild;
private Screen dynamicControl;
public ParentViewModel(Func<ChildViewModel> createChild) { this.createChild = createChild; }
public Screen DynamicControl
{
get => this.dynamicControl;
set => this.SetAndNotify(ref this.dynamicControl, value);
}
protected override void OnInitialActivate()
{
base.OnInitialActivate();
this.DynamicControl = this.createChild();
}
}
/// ChildViewModel.cs
public class ChildViewModel : Screen
{
protected override void OnInitialActivate()
{
// Never gets called
}
}
Version Info
- Stylet version: 1.3.6
- Runtime version: .NET 5