Browse Source

Fix: Exception when calling one of the context menu entries in XAML designer (like "Send to back", "Bring to front" etc.) on a root control. Example: The outermost Grid of a window.

pull/567/head
Andreas Weizel 11 years ago
parent
commit
01ac76ea2f
  1. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs

@ -46,6 +46,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -46,6 +46,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void Click_BringToFront(object sender, RoutedEventArgs e)
{
if ((designItem.ParentProperty == null) || !designItem.ParentProperty.IsCollection)
return;
var collection = this.designItem.ParentProperty.CollectionElements;
collection.Remove(this.designItem);
collection.Add(this.designItem);
@ -53,6 +56,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -53,6 +56,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void Click_SendToBack(object sender, RoutedEventArgs e)
{
if ((designItem.ParentProperty == null) || !designItem.ParentProperty.IsCollection)
return;
var collection = this.designItem.ParentProperty.CollectionElements;
collection.Remove(this.designItem);
collection.Insert(0, this.designItem);
@ -60,14 +66,20 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -60,14 +66,20 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void Click_Backward(object sender, RoutedEventArgs e)
{
if ((designItem.ParentProperty == null) || !designItem.ParentProperty.IsCollection)
return;
var collection = this.designItem.ParentProperty.CollectionElements;
var idx = collection.IndexOf(this.designItem);
collection.RemoveAt(idx);
collection.Insert((--idx < 0 ? 0: idx), this.designItem);
collection.Insert((--idx < 0 ? 0 : idx), this.designItem);
}
void Click_Forward(object sender, RoutedEventArgs e)
{
if ((designItem.ParentProperty == null) || !designItem.ParentProperty.IsCollection)
return;
var collection = this.designItem.ParentProperty.CollectionElements;
var idx = collection.IndexOf(this.designItem);
collection.RemoveAt(idx);

Loading…
Cancel
Save