From e64135beefd592ec95007ab880bac28b33bf9d73 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Sat, 31 Aug 2013 17:26:02 +0200 Subject: [PATCH 01/34] Default Placement should also work for Control, because it could have a Content Property (when the ContentPropertyAttribute is set) With this Change you can DragDrop a for Example a PieSeries into the Chart Control from the WPF Toolkit --- .../Project/Extensions/DefaultPlacementBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs index 1eaa1533f3..f7a1c0b352 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -18,10 +18,9 @@ using System.Windows.Controls.Primitives; namespace ICSharpCode.WpfDesign.Designer.Extensions { [ExtensionFor(typeof(Panel))] - [ExtensionFor(typeof(ContentControl))] + [ExtensionFor(typeof(Control))] [ExtensionFor(typeof(Border))] [ExtensionFor(typeof(Viewbox))] - [ExtensionFor(typeof(ItemsControl))] public class DefaultPlacementBehavior : BehaviorExtension, IPlacementBehavior { static List _contentControlsNotAllowedToAdd; From f4a283ff9b8a3f9b13178449d2212ab7bf7cc212 Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 10 Sep 2013 10:20:47 +0200 Subject: [PATCH 02/34] Added unit test for using SolidColorBrush as a resource. This also tests that the inner text of an XML element is only set if the element type defines a Content property. --- .../Tests/Designer/ModelTests.cs | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs index 1b0c322563..d96af12a6d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs @@ -2,17 +2,19 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Text; -using System.IO; -using System.Xml; using System.Diagnostics; +using System.IO; +using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; -using NUnit.Framework; +using System.Windows.Media; +using System.Xml; + using ICSharpCode.WpfDesign.Designer; -using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Services; +using ICSharpCode.WpfDesign.Designer.Xaml; +using NUnit.Framework; namespace ICSharpCode.WpfDesign.Tests.Designer { @@ -368,6 +370,34 @@ namespace ICSharpCode.WpfDesign.Tests.Designer { AddBindingWithStaticResourceWhereResourceOnSameElement(true); } + + [Test] + public void AddBrushAsResource() + { + DesignItem checkBox = CreateCanvasContext(""); + DesignItem canvas = checkBox.Parent; + + DesignItemProperty canvasResources = canvas.Properties.GetProperty("Resources"); + + DesignItem brush = canvas.Services.Component.RegisterComponentForDesigner(new SolidColorBrush()); + brush.Key = "testBrush"; + brush.Properties[SolidColorBrush.ColorProperty].SetValue(Colors.Fuchsia); + + Assert.IsTrue(canvasResources.IsCollection); + canvasResources.CollectionElements.Add(brush); + + checkBox.Properties[CheckBox.ForegroundProperty].SetValue(new StaticResourceExtension()); + DesignItemProperty prop = checkBox.Properties[CheckBox.ForegroundProperty]; + prop.Value.Properties["ResourceKey"].SetValue("testBrush"); + + string expectedXaml = "\n" + + " \n" + + "\n" + + ""; + + AssertCanvasDesignerOutput(expectedXaml, checkBox.Context); + AssertLog(""); + } } public class MyMultiConverter : IMultiValueConverter From 0b59cb78ae5a6b9f4c2f4f4aea0a1a8c8779ae7b Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 10 Sep 2013 13:50:18 +0200 Subject: [PATCH 03/34] Fixed ignored SetPropertyTests; Must set the property value on the DesignItem representing the object, otherwise the value will not get written to XAML. --- .../Tests/Designer/SetPropertyTests.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs index ac1ee42aa2..c1ad04f4f9 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs @@ -21,20 +21,22 @@ namespace ICSharpCode.WpfDesign.Tests.Designer AssertCanvasDesignerOutput("