Browse Source

Added support for using enums.

pull/494/head
gumme 11 years ago
parent
commit
ba913a15b5
  1. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
  2. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs

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

@ -668,6 +668,11 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -668,6 +668,11 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
}
public void AddNativeTypeAsResource(object component, string expectedXamlValue)
{
AddTypeAsResource(component, expectedXamlValue, "Controls0:", new string[] { "xmlns:Controls0=\"clr-namespace:System;assembly=mscorlib\""} );
}
public void AddTypeAsResource(object component, string expectedXamlValue, string typePrefix, String[] additionalXmlns)
{
DesignItem textBlock = CreateCanvasContext("<TextBlock/>");
DesignItem canvas = textBlock.Parent;
@ -687,11 +692,11 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -687,11 +692,11 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
string typeName = component.GetType().Name;
string expectedXaml = "<Canvas.Resources>\n" +
" <Controls0:" + typeName + " x:Key=\"res1\">" + expectedXamlValue + "</Controls0:" + typeName + ">\n" +
" <" + typePrefix + typeName + " x:Key=\"res1\">" + expectedXamlValue + "</" + typePrefix + typeName + ">\n" +
"</Canvas.Resources>\n" +
"<TextBlock Tag=\"{StaticResource ResourceKey=res1}\" />";
AssertCanvasDesignerOutput(expectedXaml, textBlock.Context, "xmlns:Controls0=\"clr-namespace:System;assembly=mscorlib\"");
AssertCanvasDesignerOutput(expectedXaml, textBlock.Context, additionalXmlns);
AssertLog("");
}
@ -736,6 +741,18 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -736,6 +741,18 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
const int i = 123;
AddNativeTypeAsResource(i, "123");
}
[Test]
public void AddWpfEnumAsResource()
{
AddTypeAsResource(VerticalAlignment.Center, "Center", "", new string[0]);
}
[Test]
public void AddCustomEnumAsResource()
{
AddTypeAsResource(MyEnum.One, "One", "t:", new string[0]);
}
}
public class MyMultiConverter : IMultiValueConverter
@ -760,4 +777,9 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -760,4 +777,9 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
set { stringProp = value; }
}
}
public enum MyEnum
{
One, Two
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs

@ -275,7 +275,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -275,7 +275,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
bool IsNativeType(object instance)
{
return instance.GetType().Assembly == typeof(String).Assembly;
return instance.GetType().Assembly == typeof(String).Assembly || instance.GetType().IsEnum;
}
}
}

Loading…
Cancel
Save