Example #1
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            // AD wants to add the anchorable into destinationContainer

            var content = anchorableToShow.Content as PaneViewModel;

            logger.DebugFormat("before insert {0} to {1}",
                               anchorableToShow.Content,
                               destinationContainer == null ? "''" :
                               string.Format("{0} with {1} childs", destinationContainer.GetType().Name, destinationContainer.ChildrenCount));

            string id = content != null ? content.ContentId : anchorableToShow.ContentId;

            var panes = layout.LayoutAnchorablePanes();
            var anchs = layout.LayoutAnchorables();
            var pane  = panes.FirstOrDefault(d => d.Name == id);

            if (pane != null)
            {
                if (content != null)
                {
                    // already have VM, after IsVisible = true
                }
                pane.Children.Add(anchorableToShow);
                return(true);
            }
            return(false);
        }