Browse Source

Support for ControlTemplates in XAML Designer

pull/593/head
jogibear9988 11 years ago
parent
commit
f53786597b
  1. 84
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs
  2. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

84
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs

@ -398,6 +398,90 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -398,6 +398,90 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
</Window>");
}
[Test]
public void Style1()
{
TestLoading(@"<Window xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button Content=""Button""
Width=""75""
Height=""23"">
<Button.Style>
<Style TargetType=""Button"">
<Setter Property=""Template"">
<Setter.Value>
<ControlTemplate TargetType=""Button"">
<Grid />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Canvas>
</Window>");
}
[Test]
public void Style2()
{
TestLoading(@"<Window xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button Content=""Button""
Width=""75""
Height=""23"">
<Button.Style>
<Style TargetType=""Button"">
<Setter Property=""Template"">
<Setter.Value>
<ControlTemplate TargetType=""Button"">
<Grid HorizontalAlignment=""Left"">
<Rectangle />
<TextBlock Text=""AA"" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Canvas>
</Window>");
}
[Test]
[Ignore("Xaml writer creates different XAML")]
public void Style3()
{
TestLoading(@"<Window xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button Content=""Button""
Width=""75""
Height=""23"">
<Button.Style>
<Style TargetType=""Button"">
<Setter Property=""Template"">
<Setter.Value>
<ControlTemplate TargetType=""Button"">
<Grid>
<Ellipse Fill=""{TemplateBinding Background}""
Stroke=""{TemplateBinding BorderBrush}""/>
<ContentPresenter HorizontalAlignment=""Center""
VerticalAlignment=""Center""/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Canvas>
</Window>");
}
[Test]
public void ListBox1()
{

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -224,7 +224,14 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -224,7 +224,14 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
if (PropertyValue != null) {
try {
ValueOnInstance = PropertyValue.GetValueFor(propertyInfo);
if (propertyInfo.ReturnType == typeof (FrameworkElementFactory))
{
ValueOnInstance = TemplateHelper.XamlObjectToFrameworkElementFactory((XamlObject) PropertyValue);
}
else
{
ValueOnInstance = PropertyValue.GetValueFor(propertyInfo);
}
if (this.parentObject.XamlSetTypeConverter != null)
this.ParentObject.XamlSetTypeConverter(this.parentObject.Instance, new XamlSetTypeConverterEventArgs(this.SystemXamlMemberForProperty, null, ((XamlTextValue) propertyValue).Text, this.parentObject.OwnerDocument.GetTypeDescriptorContext(this.parentObject), null));

Loading…
Cancel
Save