Browse Source

Merge branch 'style-initialized'

pull/496/head
Steven Kirk 11 years ago
parent
commit
9c12fe4462
  1. 10
      tests/Perspex.Markup.Xaml.UnitTests/Perspex.Markup.Xaml.UnitTests.csproj
  2. 8
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style1.xaml
  3. 9
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style2.xaml
  4. 26
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/StyleTests.cs

10
tests/Perspex.Markup.Xaml.UnitTests/Perspex.Markup.Xaml.UnitTests.csproj

@ -174,6 +174,16 @@
<ItemGroup> <ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Xaml\Style1.xaml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Xaml\Style2.xaml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Choose> <Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'"> <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup> <ItemGroup>

8
tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style1.xaml

@ -0,0 +1,8 @@
<Style xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style.Resources>
<Color x:Key="Red">Red</Color>
<Color x:Key="Green">Green</Color>
<Color x:Key="Blue">Blue</Color>
</Style.Resources>
</Style>

9
tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style2.xaml

@ -0,0 +1,9 @@
<Style xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mut="https://github.com/perspex/mutable">
<Style.Resources>
<mut:SolidColorBrush x:Key="RedBrush" Color="{StyleResource Red}"/>
<mut:SolidColorBrush x:Key="GreenBrush" Color="{StyleResource Green}"/>
<mut:SolidColorBrush x:Key="BlueBrush" Color="{StyleResource Blue}"/>
</Style.Resources>
</Style>

26
tests/Perspex.Markup.Xaml.UnitTests/Xaml/StyleTests.cs

@ -198,5 +198,31 @@ namespace Perspex.Markup.Xaml.UnitTests.Xaml
Assert.Equal(0xff506070, brush.Color.ToUint32()); Assert.Equal(0xff506070, brush.Color.ToUint32());
} }
[Fact(Skip = "TODO: Issue #492")]
public void StyleResource_Can_Be_Found_Across_Xaml_Files()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = @"
<Window xmlns='https://github.com/perspex'
xmlns:mut='https://github.com/perspex/mutable'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Window.Styles>
<StyleInclude Source='resm:Perspex.Markup.Xaml.UnitTests.Xaml.Style1.xaml?assembly=Perspex.Markup.Xaml.UnitTests'/>
<StyleInclude Source='resm:Perspex.Markup.Xaml.UnitTests.Xaml.Style2.xaml?assembly=Perspex.Markup.Xaml.UnitTests'/>
</Window.Styles>
<Border Name='border' Background='{StyleResource RedBrush}'/>
</Window>";
var loader = new PerspexXamlLoader();
var window = (Window)loader.Load(xaml);
var border = window.FindControl<Border>("border");
var borderBrush = (Perspex.Media.Mutable.SolidColorBrush)border.Background;
Assert.NotNull(borderBrush);
Assert.Equal(0xffff0000, borderBrush.Color.ToUint32());
}
}
} }
} }

Loading…
Cancel
Save