public void CloseWidget(WidgetControl widget)
        {
            if (WidgetsViewModels.Remove(widget.ViewModel))
            {
                /*var index = View.WidgetsPanel.Children.IndexOf(widget);
                 * var dropholder = View.WidgetsPanel.Children[index - 1];
                 * View.WidgetsPanel.Children.Remove(widget);
                 * View.WidgetsPanel.Children.Remove(dropholder);*/
                var index = View.WidgetsPanel.IndexOf(widget);
                View.WidgetsPanel.RemoveElement(widget);
#if alldbg || dbg
                DumpWidgetsPanelChildren();
#endif
            }
        }
 public void AddWidget(WidgetControl widget, int targetIndex = -1)
 {
     WidgetsViewModels.Add(widget.ViewModel);
     widget.ViewModel.PanelViewModel = this;
     if (targetIndex == -1)
     {
         /*View.WidgetsPanel.Children.Add(GetNewWidgetStackPanelDropPlaceHolder());
          * View.WidgetsPanel.Children.Add(widget);*/
         View.WidgetsPanel.AddElement(widget);
     }
     else
     {
         /*View.WidgetsPanel.Children.Insert(targetIndex, widget);
          * View.WidgetsPanel.Children.Insert(targetIndex, GetNewWidgetStackPanelDropPlaceHolder());*/
     }
 }
        void OnDeserialized(StreamingContext context)
        {
            var widgets = new List <WidgetBaseViewModel>(WidgetsViewModels);

            WidgetsViewModels.Clear();
            foreach (var widget in widgets)
            {
                AddWidget(widget.View);
            }
            DesktopPanelToolService.AddDesktopPanel(
                View,
                _dock,
                _dockScreen,
                _isPined,
                _isCollapsed
                );
        }