Nested View Activation

Topics: Conventions, Framework Services
May 24, 2011 at 1:25 AM

I am trying to create a WPF application with nested views in it. Basically the outlay is as follows

Shell Window =>  Chart => Demographics

                                           => Financials

                                           => Notes

I can switch in the ShellViewModel perfectly using a ContentControl with the name of ActiveItem .... now I am trying to wire up the ChartViewModel

to switch in between the sub-views using the same logic...ContentControl x:Name="ActiveItem"  and using the ActivateItem(Screen ) method. However,

it seems to be set as the ActiveItem...but IsActive=False and it does not display in the ContentControl??

Any ideas here on what I am screwing up?


May 24, 2011 at 8:17 AM

Are you sure that the item is activated in the view-model? Remember that a Conductor used inside the shell is activated automatically by the WindowManager, while other conductors have to be activated by hand, under certain scenarios.

May 24, 2011 at 12:11 PM
Edited May 24, 2011 at 12:12 PM

If you use nested views (viewmodels) but no conductor you can also use some extension methods to activate the nested viewmodels



    public class ShellViewModel : Screen
        private NestedViewModel _nested;

        public ShellViewModel(NestedViewModel nested)
            _nested1 = nested;

            // ConductWith is ActivateWith+DeactivateWith

    public class NestedViewModel : Screen { }

Another way would be to override OnActivate()/OnDeativate() in the shell and do the activation logic for the nested views there

Oct 3, 2014 at 1:38 PM
I have a similar situation, but the _nested property, instead of being set in the constructor, is exposed as a public property that can be changed, something like this:
public NestedViewModel Nested
                return this._nested;
                if (this._nested!= value)
                    if (this._nested!= null)
                        // How can undo this?
                    this._nested= value;
                    if (this._nested!= null)
                    this.NotifyOfPropertyChange(() => this.Nested);
My point is that I need to undo the ConductWith(this) action from the old value of the _nested object when it gets replaced.
How ca i do that?