Browse Source

Remove Name from a Pasted Control when it exists in the NameScope

pull/52/head
jkuehner 12 years ago
parent
commit
4573eeec9c
  1. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
  2. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs

@ -86,6 +86,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -86,6 +86,9 @@ namespace ICSharpCode.WpfDesign.Designer
if (selectionService.SelectionCount == 0 && !items.Contains(parent)) {
selectionService.SetSelectedComponents(new DesignItem[] { parent });
}
foreach (var designItem in items) {
designItem.Name = null;
}
operation.DeleteItemsAndCommit();
} catch {
operation.Abort();

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs

@ -5,6 +5,7 @@ using System; @@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Windows.Markup;
using System.Windows;
using ICSharpCode.WpfDesign.XamlDom;
@ -87,6 +88,14 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -87,6 +88,14 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
if (ComponentRegistered != null) {
ComponentRegistered(this, new DesignItemEventArgs(site));
}
if (_context.RootItem != null && !string.IsNullOrEmpty(site.Name)) {
var nameScope = _context.RootItem.Component as INameScope;
nameScope = NameScope.GetNameScope((DependencyObject) _context.RootItem.Component);
var fnd = nameScope.FindName(site.Name);
if (fnd != null)
site.Name = null;
}
return site;
}
}

Loading…
Cancel
Save