diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs
index d95b53b0aa..827ccd037c 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs
@@ -291,7 +291,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
" \n" +
"\n" +
"\n" +
- "\n";
+ "\n";
AssertGridDesignerOutput(expectedXaml, grid.Context,
"xmlns:Controls0=\"clr-namespace:ICSharpCode.WpfDesign.Tests.Designer;assembly=ICSharpCode.WpfDesign.Tests\"",
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 1419521e82..9356d98579 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
@@ -553,7 +553,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
textBox.Properties[TextBox.TextProperty].Value.Properties["Path"].SetValue("SomeProperty");
string expectedXaml = "\n" +
- "\n";
+ "\n";
AssertCanvasDesignerOutput(expectedXaml, button.Context);
AssertLog("");
@@ -583,7 +583,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
" \n" +
"\n" +
"\n" +
- "";
+ "";
AssertCanvasDesignerOutput(expectedXaml, button.Context);
AssertLog("");
@@ -620,7 +620,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
" \n" +
" \n" +
" \n" +
- " \n" +
+ " \n" +
"";
AssertCanvasDesignerOutput(expectedXaml, button.Context);
@@ -689,7 +689,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
string expectedXaml = "\n" +
" \n" +
"\n" +
- "";
+ "";
AssertCanvasDesignerOutput(expectedXaml, checkBox.Context);
AssertLog("");
@@ -722,7 +722,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
string expectedXaml = "\n" +
" <" + typePrefix + typeName + " x:Key=\"res1\">" + expectedXamlValue + "" + typePrefix + typeName + ">\n" +
"\n" +
- "";
+ "";
AssertCanvasDesignerOutput(expectedXaml, textBlock.Context, additionalXmlns);
AssertLog("");
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 a290813f16..b031e01e57 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/SetPropertyTests.cs
@@ -44,7 +44,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
button.Properties.GetProperty("Content").SetValue(new StaticResourceExtension());
button.Properties.GetProperty("Content").Value.Properties["ResourceKey"].SetValue("MyBrush");
// TODO : maybe we should support positional arguments from ctors as well => {StaticResource MyBrush}?
- AssertCanvasDesignerOutput("", button.Context);
+ AssertCanvasDesignerOutput("", button.Context);
}
[Test]
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
index dd23b6eef2..c2b1ba243b 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
@@ -20,6 +20,9 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Windows;
+using System.Windows.Data;
+using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
{
@@ -34,7 +37,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
public static bool CanPrint(XamlObject obj)
{
if (obj.ElementType == typeof(System.Windows.Data.MultiBinding) ||
- obj.ElementType == typeof(System.Windows.Data.PriorityBinding)) {
+ obj.ElementType == typeof(System.Windows.Data.PriorityBinding)) {
return false;
}
@@ -51,7 +54,37 @@ namespace ICSharpCode.WpfDesign.XamlDom
sb.Append(obj.GetNameForMarkupExtension());
bool first = true;
- foreach (var property in obj.Properties) {
+ var properties = obj.Properties.ToList();
+
+ if (obj.ElementType == typeof(Binding)){
+ var p=obj.Properties.FirstOrDefault(x=>x.PropertyName=="Path");
+ if (p!=null && p.IsSet) {
+ sb.Append(" ");
+ AppendPropertyValue(sb, p.PropertyValue);
+ properties.Remove(p);
+ first = false;
+ }
+ }
+ else if (obj.ElementType == typeof(Reference)){
+ var p=obj.Properties.FirstOrDefault(x=>x.PropertyName=="Name");
+ if (p!=null && p.IsSet) {
+ sb.Append(" ");
+ AppendPropertyValue(sb, p.PropertyValue);
+ properties.Remove(p);
+ first = false;
+ }
+ }
+ else if (obj.ElementType == typeof(StaticResourceExtension)){
+ var p=obj.Properties.FirstOrDefault(x=>x.PropertyName=="ResourceKey");
+ if (p!=null && p.IsSet) {
+ sb.Append(" ");
+ AppendPropertyValue(sb, p.PropertyValue);
+ properties.Remove(p);
+ first = false;
+ }
+ }
+
+ foreach (var property in properties) {
if (!property.IsSet) continue;
if (first)
@@ -63,29 +96,33 @@ namespace ICSharpCode.WpfDesign.XamlDom
sb.Append(property.GetNameForMarkupExtension());
sb.Append("=");
- var value = property.PropertyValue;
- var textValue = value as XamlTextValue;
- if (textValue != null) {
- string text = textValue.Text;
- bool containsSpace = text.Contains(' ');
-
- if(containsSpace) {
- sb.Append('\'');
- }
-
- sb.Append(text.Replace("\\", "\\\\"));
-
- if(containsSpace) {
- sb.Append('\'');
- }
- } else if (value is XamlObject) {
- sb.Append(Print(value as XamlObject));
- }
+ AppendPropertyValue(sb, property.PropertyValue);
}
sb.Append("}");
return sb.ToString();
}
+ private static void AppendPropertyValue(StringBuilder sb, XamlPropertyValue value)
+ {
+ var textValue = value as XamlTextValue;
+ if (textValue != null) {
+ string text = textValue.Text;
+ bool containsSpace = text.Contains(' ');
+
+ if(containsSpace) {
+ sb.Append('\'');
+ }
+
+ sb.Append(text.Replace("\\", "\\\\"));
+
+ if(containsSpace) {
+ sb.Append('\'');
+ }
+ } else if (value is XamlObject) {
+ sb.Append(Print(value as XamlObject));
+ }
+ }
+
private static bool CanPrint(XamlObject obj, bool isNested, XamlObject nonMarkupExtensionParent)
{
if ((isNested || obj.ParentObject == nonMarkupExtensionParent) && IsStaticResourceThatReferencesLocalResource(obj, nonMarkupExtensionParent)) {