Browse Source

Fixed bug; CanPrint was only checked for the first property using nested markup extension.

pull/617/head
gumme 11 years ago
parent
commit
8d47f04678
  1. 32
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
  2. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs

32
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs

@ -596,7 +596,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -596,7 +596,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
DesignItem textBox = canvas.Services.Component.RegisterComponentForDesigner(new TextBox());
canvas.Properties["Children"].CollectionElements.Add(textBox);
DesignItemProperty resProp = textBox.Properties.GetProperty("Resources");
DesignItemProperty resProp = button.Properties.GetProperty("Resources");
Assert.IsTrue(resProp.IsCollection);
DesignItem dummyItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass());
dummyItem.Key = "dummy";
resProp.CollectionElements.Add(dummyItem);
resProp = textBox.Properties.GetProperty("Resources");
Assert.IsTrue(resProp.IsCollection);
DesignItem exampleClassItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass());
exampleClassItem.Key = "bindingSource";
@ -605,23 +611,33 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -605,23 +611,33 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
DesignItem bindingItem = canvas.Services.Component.RegisterComponentForDesigner(new Binding());
if (!setBindingPropertiesAfterSet) {
bindingItem.Properties["Path"].SetValue("StringProp");
// Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding
bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension());
bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy");
bindingItem.Properties["Source"].SetValue(new StaticResourceExtension());
bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource");
}
textBox.Properties[TextBox.TextProperty].SetValue(bindingItem);
if (setBindingPropertiesAfterSet) {
bindingItem.Properties["Path"].SetValue("StringProp");
// Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding
bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension());
bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy");
bindingItem.Properties["Source"].SetValue(new StaticResourceExtension());
bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource");
}
string expectedXaml = "<Button />\n" +
"<TextBox>\n" +
" <TextBox.Resources>\n" +
" <t:ExampleClass x:Key=\"bindingSource\" />\n" +
" </TextBox.Resources>\n" +
" <Binding Path=\"StringProp\" Source=\"{StaticResource bindingSource}\" />\n" +
"</TextBox>";
const string expectedXaml = "<Button>\n" +
" <Button.Resources>\n" +
" <t:ExampleClass x:Key=\"dummy\" />\n" +
" </Button.Resources>\n" +
"</Button>\n" +
"<TextBox>\n" +
" <TextBox.Resources>\n" +
" <t:ExampleClass x:Key=\"bindingSource\" />\n" +
" </TextBox.Resources>\n" +
" <Binding Path=\"StringProp\" ConverterParameter=\"{StaticResource dummy}\" Source=\"{StaticResource bindingSource}\" />\n" +
"</TextBox>";
AssertCanvasDesignerOutput(expectedXaml, button.Context);
AssertLog("");

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs

@ -137,8 +137,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -137,8 +137,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
var xamlObject = value as XamlObject;
if (xamlObject == null || !xamlObject.IsMarkupExtension)
return false;
else
return CanPrint(xamlObject, true, nonMarkupExtensionParent);
else if (!CanPrint(xamlObject, true, nonMarkupExtensionParent))
return false;
}
}

Loading…
Cancel
Save