private IEnumerable<ViewModel> VisitLayoutItem(ViewModel element)
        {
            var elementList = element.Bindable as ElementListLayout;
            if (elementList != null) return RecurseElementList(elementList);

            var listLayout = element.Bindable as ListLayout;
            if (listLayout != null) return RecurseListLayout(listLayout);

            var twoColumn = element.Bindable as TwoColumnsLayout;
            if (twoColumn != null) return RecurseTwoColumnLayout(twoColumn);

            return Enumerable.Empty<ViewModel>();
        }
        private HorizontalListLayout(IEnumerable<ViewModel> elements, int nestingDepth, HorizontalListLayout root, IElementChangeScope changeScope)
        {
            this.nestingDepth = nestingDepth;

            this.current = elements.First();
            this.hasNext = elements.Count() > 1;
            this.elements = elements;

            rootListLayout = root ?? this;

            OwnsResizing = true;

            this.changeScope = changeScope;
            if (this.changeScope != null)
            {
                this.changeScope.CollectionChanged += ForcePropertyRequery;
            }
        }
        /// <summary>
        /// Initializes a new <see cref="ElementListLayoutWalker"/>.
        /// </summary>
        /// <param name="root">Root <see cref="ViewModel"/>'s bindable is expected to be one of <br/>
        /// <list>
        /// <item><see cref="ElementListLayout"/></item>
        /// <item><see cref="ListLayout"/></item>
        /// <item><see cref="TwoColumnsLayout"/></item>
        /// </list>
        /// 
        /// If it is not one of these classes <see cref="ElementListLayoutWalker"/> will
        /// return empty at all times.
        /// </param>
        public ElementListLayoutWalker(ViewModel root)
        {
            if (root == null) throw new ArgumentNullException("root");

            this.root = root;
        }
 /// <summary>
 /// Initializes a new instance of <see cref="TwoVerticalsLayout"/>.
 /// </summary>
 /// <param name="first">The first <see cref="ViewModel"/> instance.</param>
 /// <param name="second">The second <see cref="ViewModel"/> instance.</param>
 public TwoVerticalsLayout(ViewModel first, ViewModel second)
 {
     this.first = first;
     this.second = second;
 }
        /// <summary>
        /// Initializes a new instance of <see cref="ThreeVerticalVisualsLayout"/>.
        /// </summary>
        /// <param name="first">The first <see cref="ViewModel"/> instance.</param>
        /// <param name="second">The second <see cref="ViewModel"/> instance.</param>
        /// <param name="third">The third <see cref="ViewModel"/> instance.</param>
        public ThreeVerticalVisualsLayout(ViewModel first, ViewModel second, ViewModel third)
            :base(first, new TwoVerticalsLayout(second, third))
        {

        }
        /// <summary>
        /// Initializes a new instance of <see cref="HorizontalColumnBindingLayout"/>.
        /// </summary>
        /// <param name="element">The <see cref="ElementViewModel"/> isntance that should be displayed.</param>
        /// <param name="columnIndex">The 0-based column index that should be used to display and resize the <paramref name="element"/>. </param>
        public HorizontalColumnBindingLayout(ViewModel element, int columnIndex)
            : base(element, null, columnIndex)
        {

        }
 /// <summary>
 /// Initializes a new instance of <see cref="ThreeVerticalVisualsLayout"/>.
 /// </summary>
 /// <param name="first">The first <see cref="ViewModel"/> instance.</param>
 /// <param name="second">The second <see cref="ViewModel"/> instance.</param>
 /// <param name="third">The third <see cref="ViewModel"/> instance.</param>
 public ThreeVerticalVisualsLayout(ViewModel first, ViewModel second, ViewModel third)
     : base(first, new TwoVerticalsLayout(second, third))
 {
 }
 /// <summary>
 /// Initializes a new instance of <see cref="TwoColumnsLayout"/>.
 /// </summary>
 /// <param name="left">The <see cref="ViewModel"/> instance that should be shown on the left.</param>
 /// <param name="right">The <see cref="ViewModel"/> instance that should be shown on the right.</param>
 /// <param name="columnIndex">The 0-based column index that should be used to display and resize the <paramref name="left"/> element. </param>
 public TwoColumnsLayout(ViewModel left, ViewModel right, int columnIndex)
 {
     this.left = left;
     this.right = right;
     this.columnIndex = columnIndex;
 }