private void Ungroup(object sender, ExecutedRoutedEventArgs e)
        {
            List <ICanvasItem> selectedCanvasItems = DesignSurface.GetSelectedCanvasItems().ToList();


            using (RecordingServices.DefaultRecorder.OpenScope("Ungroup"))
            {
                foreach (var selectedItem in selectedCanvasItems)
                {
                    selectedItem.RemoveAndPromoteChildren();
                    this.DesignSurface.CanvasDocument.Children.Remove(selectedItem);
                }
            }
        }
        private void Group(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs)
        {
            var groupCommandArgs = (GroupCommandArgs)executedRoutedEventArgs.Parameter;

            IEnumerable <ICanvasItem> items = DesignSurface.GetSelectedCanvasItems().ToList();
            ICanvasItem group = groupCommandArgs.CreateHostingItem();

            using (RecordingServices.DefaultRecorder.OpenScope("Group"))
            {
                // We have to *first* add the group to the document to make it recordable.
                this.DesignSurface.CanvasDocument.Children.Add(@group);

                items.Reparent(@group);
            }
        }
 private void CanUngroup(object sender, CanExecuteRoutedEventArgs e)
 {
     e.CanExecute = DesignSurface.GetSelectedCanvasItems().All(item => item.Children.Any());
 }
        private void AlignHorizontally(HorizontalAlignment alignment)
        {
            var aligner = new Aligner(DesignSurface.GetSelectedCanvasItems());

            aligner.AlignHorizontally(alignment);
        }