private void TreeViewItemDrop(object sender, DragEventArgs e)
        {
            Grid item = sender as Grid;

            if (item != null)
            {
                var newStyleItemParent = ((StyleItemViewModel)e.Data.GetData(typeof(StyleItemViewModel))).StyleItem.Parent as StyleLayerListItem;
                if (newStyleItemParent != null)
                {
                    if (draggingItemParent != null)
                    {
                        draggingItemParent.UpdateConcreteObject();
                        var parentUI = draggingItemParent.GetUI(multiStyleBuilderViewModel.SelectedStyleBuilderViewModel.StyleArguments);
                        if (parentUI != null)
                        {
                            draggingItemParent.UpdateUI(parentUI);
                        }
                    }

                    if (newStyleItemParent != draggingItemParent)
                    {
                        newStyleItemParent.UpdateConcreteObject();
                        var parentUI = newStyleItemParent.GetUI(multiStyleBuilderViewModel.SelectedStyleBuilderViewModel.StyleArguments);
                        if (parentUI != null)
                        {
                            newStyleItemParent.UpdateUI(parentUI);
                        }
                    }

                    multiStyleBuilderViewModel.SelectedStyleBuilderViewModel.UpdatePreviewSource();
                }
            }
        }
 private void RefreshUI(StyleLayerListItem styleItem)
 {
     if (styleItem != null)
     {
         styleItem.UpdateConcreteObject();
         var styleItemUI = styleItem.GetUI(styleArguments);
         if (styleItemUI != null)
         {
             styleItem.UpdateUI(styleItemUI);
         }
     }
 }
        private void ReplaceFromLibrary(object sender, RoutedEventArgs e)
        {
            var styleLibraryWindow = new StyleLibraryWindow();

            if (styleLibraryWindow.ShowDialog().GetValueOrDefault())
            {
                var compositeStyle = styleItem.ConcreteObject as CompositeStyle;

                //styleLibraryWindow.Result.CompositeStyle
                var compositeStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(styleLibraryWindow.Result.CompositeStyle);
                if (compositeStyle != null)
                {
                    styleItem.Children.Clear();
                    styleItem.Name = compositeStyleItem.Name;
                    foreach (var item in compositeStyleItem.Children)
                    {
                        styleItem.Children.Add(item);
                    }
                    styleItem.UpdateConcreteObject();
                }
                else
                {
                    var parentStyleitem = styleItem.Parent as StyleLayerListItem;
                    if (parentStyleitem != null)
                    {
                        var index = parentStyleitem.Children.IndexOf(styleItem);
                        parentStyleitem.Children.RemoveAt(index);
                        foreach (var item in compositeStyleItem.Children)
                        {
                            parentStyleitem.Children.Insert(index, item);
                            index++;
                        }
                        parentStyleitem.UpdateConcreteObject();
                    }
                }
            }
        }