Browse Source

support Attached property in property type converter

pull/916/head
donandren 10 years ago
committed by Andrey Kunchev
parent
commit
e6cd080081
  1. 3
      src/Markup/Avalonia.Markup.Xaml/Converters/AvaloniaPropertyTypeConverter.cs
  2. 27
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs

3
src/Markup/Avalonia.Markup.Xaml/Converters/AvaloniaPropertyTypeConverter.cs

@ -48,7 +48,8 @@ namespace Avalonia.Markup.Xaml.Converters
} }
else else
{ {
//type = context.TypeRepository.GetByQualifiedName(typeName)?.UnderlyingType; var typeResolver = context.GetService<IXamlTypeResolver>();
type = typeResolver.Resolve(typeName);
if (type == null) if (type == null)
{ {

27
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs

@ -221,6 +221,31 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
Assert.Equal(100.0, setters[1].Value); Assert.Equal(100.0, setters[1].Value);
} }
[Fact]
public void Style_Setter_With_AttachedProperty_Is_Parsed()
{
var xaml = @"
<Styles xmlns='https://github.com/avaloniaui'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Style Selector='ContentControl'>
<Setter Property='TextBlock.FontSize' Value='21'/>
</Style>
</Styles>";
var styles = AvaloniaXamlLoader.Parse<Styles>(xaml);
Assert.Equal(1, styles.Count);
var style = (Style)styles[0];
var setters = style.Setters.Cast<Setter>().ToArray();
Assert.Equal(1, setters.Length);
Assert.Equal(TextBlock.FontSizeProperty, setters[0].Property);
Assert.Equal(21.0, setters[0].Value);
}
[Fact] [Fact]
public void Complex_Style_Is_Parsed() public void Complex_Style_Is_Parsed()
{ {
@ -317,7 +342,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
var xaml = @" var xaml = @"
<Styles xmlns='https://github.com/avaloniaui' <Styles xmlns='https://github.com/avaloniaui'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<StyleInclude Source='resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default'/> <StyleInclude Source='resm:Avalonia.Themes.Default.ContextMenu.xaml?assembly=Avalonia.Themes.Default'/>
</Styles>"; </Styles>";
var styles = AvaloniaXamlLoader.Parse<Styles>(xaml); var styles = AvaloniaXamlLoader.Parse<Styles>(xaml);

Loading…
Cancel
Save