|
Description To Reproduce /// 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
|
Replies: 1 comment 4 replies
|
(Converted this support request to a discussion. Please read the issue template). The parent doesn't know that the child exists. How would it? It's therefore impossible to know that there's something which needs to be activated. You can use a You can also use |
(Converted this support request to a discussion. Please read the issue template).
The parent doesn't know that the child exists. How would it? It's therefore impossible to know that there's something which needs to be activated.
You can use a
Conductor<IScreen>, and setActiveItemrather than having aDynamicItemproperty: the conductor knows that theActiveItemproperty contains a child which needs to be activated/etc. See the documentation.You can also use
child.ConductWith(parent)for long-lived children, but don't do this if the child might be destroyed before the parent.