Browse Source

Content should be Addable to all ContentControls

pull/604/head
jkuehner 11 years ago
parent
commit
f92e6bef3b
  1. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  2. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs

@ -38,27 +38,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -38,27 +38,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
[ExtensionFor(typeof(Viewbox))]
public class DefaultPlacementBehavior : BehaviorExtension, IPlacementBehavior
{
static List<Type> _contentControlsNotAllowedToAdd;
static DefaultPlacementBehavior()
{
_contentControlsNotAllowedToAdd = new List<Type>();
_contentControlsNotAllowedToAdd.Add(typeof (Frame));
_contentControlsNotAllowedToAdd.Add(typeof (GroupItem));
_contentControlsNotAllowedToAdd.Add(typeof (HeaderedContentControl));
_contentControlsNotAllowedToAdd.Add(typeof (Label));
_contentControlsNotAllowedToAdd.Add(typeof (ListBoxItem));
//_contentControlsNotAllowedToAdd.Add(typeof (ButtonBase));
_contentControlsNotAllowedToAdd.Add(typeof (StatusBarItem));
_contentControlsNotAllowedToAdd.Add(typeof (ToolTip));
}
{ }
public static bool CanContentControlAdd(ContentControl control)
{
Debug.Assert(control != null);
return !_contentControlsNotAllowedToAdd.Any(type => type.IsAssignableFrom(control.GetType()));
}
protected override void OnInitialized()
{
base.OnInitialized();
@ -158,12 +140,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -158,12 +140,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (ExtendedItem.ContentProperty.IsCollection)
return CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType,
operation.PlacedItems.Select(p => p.Item.Component));
if (ExtendedItem.View is ContentControl) {
if (!CanContentControlAdd((ContentControl) ExtendedItem.View)) {
return false;
}
}
if (ExtendedItem.ContentProperty.ReturnType == typeof(string))
return false;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs

@ -131,7 +131,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -131,7 +131,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
AddInParent(parent, pastedItems);
pasted = true;
}
} else if (pastedItems.Count == 1 && parent.ContentProperty.Value == null && parent.ContentProperty.ValueOnInstance == null && parent.View is ContentControl && DefaultPlacementBehavior.CanContentControlAdd((ContentControl)parent.View)) {
} else if (pastedItems.Count == 1 && parent.ContentProperty.Value == null && parent.ContentProperty.ValueOnInstance == null && parent.View is ContentControl) {
AddInParent(parent, pastedItems);
pasted = true;
}

Loading…
Cancel
Save