Browse Source

Added Carousel and CheckBox XAML styles.

pull/297/head
Steven Kirk 11 years ago
parent
commit
25fa7ddc6a
  1. 3
      samples/XamlTestApplicationPcl/Button.paml
  2. 16
      samples/XamlTestApplicationPcl/Carousel.paml
  3. 30
      samples/XamlTestApplicationPcl/CheckBox.paml
  4. 2
      samples/XamlTestApplicationPcl/XamlTestApp.paml
  5. 6
      samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj
  6. 2
      src/Markup/Perspex.Markup.Xaml/Templates/ControlTemplate.cs
  7. 2
      src/Perspex.Controls/ContentControl.cs
  8. 8
      tests/Perspex.Controls.UnitTests/ContentControlTests.cs
  9. 2
      tests/Perspex.Controls.UnitTests/Primitives/PopupTests.cs
  10. 2
      tests/Perspex.Controls.UnitTests/Utils/HotKeyManagerTests.cs

3
samples/XamlTestApplicationPcl/Button.paml

@ -7,13 +7,14 @@
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<ControlTemplate>
<Border Name="border"
Padding="3"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter Content="{TemplateBinding Content}"
Margin="{TemplateBinding Padding}"
TextBlock.Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>

16
samples/XamlTestApplicationPcl/Carousel.paml

@ -0,0 +1,16 @@
<Style xmlns="https://github.com/perspex" Selector="Carousel">
<Setter Property="Template">
<ControlTemplate>
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<CarouselPresenter Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
Margin="{TemplateBinding Padding}"
MemberSelector="{TemplateBinding MemberSelector}"
SelectedIndex="{TemplateBinding SelectedIndex}"
Transition="{TemplateBinding Transition}"/>
</Border>
</ControlTemplate>
</Setter>
</Style>

30
samples/XamlTestApplicationPcl/CheckBox.paml

@ -0,0 +1,30 @@
<Styles xmlns="https://github.com/perspex">
<Style Selector="CheckBox">
<Setter Property="BorderBrush" Value="#ff333333"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Template">
<ControlTemplate>
<Grid ColumnDefinitions="Auto,*">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Width="18"
Height="18"
VerticalAlignment="Center"/>
<Path Name="checkMark"
Fill="#ff333333"
Width="11"
Height="10"
Stretch="Uniform"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 1145.607177734375,430 C1145.607177734375,430 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1138,434.5538330078125 1138,434.5538330078125 1138,434.5538330078125 1141.482177734375,438 1141.482177734375,438 1141.482177734375,438 1141.96875,437.9375 1141.96875,437.9375 1141.96875,437.9375 1147,431.34619140625 1147,431.34619140625 1147,431.34619140625 1145.607177734375,430 1145.607177734375,430 z"/>
<ContentPresenter Name="PART_ContentPresenter"
Content="{TemplateBinding Content}"
Margin="4,0,0,0"
VerticalAlignment="Center"
Grid.Column="1"/>
</Grid>
</ControlTemplate>
</Setter>
</Style>
</Styles>

2
samples/XamlTestApplicationPcl/XamlTestApp.paml

@ -3,5 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Styles>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Button.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Carousel.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.CheckBox.paml"/>
</Application.Styles>
</Application>

6
samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj

@ -123,6 +123,12 @@
<EmbeddedResource Include="XamlTestApp.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Carousel.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="CheckBox.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="packages.config" />
<EmbeddedResource Include="Button.paml">
<SubType>Designer</SubType>

2
src/Markup/Perspex.Markup.Xaml/Templates/ControlTemplate.cs

@ -11,8 +11,6 @@ namespace Perspex.Markup.Xaml.Templates
{
public class ControlTemplate : IControlTemplate
{
public Type TargetType { get; set; }
[Content]
public TemplateContent Content { get; set; }

2
src/Perspex.Controls/ContentControl.cs

@ -102,7 +102,7 @@ namespace Perspex.Controls
// We allow ContentControls without ContentPresenters in the template. This can be
// useful for e.g. a simple ToggleButton that displays an image. There's no need to
// have a ContentPresenter in the visual tree for that.
Presenter = this.FindTemplateChild<ContentPresenter>("contentPresenter");
Presenter = this.FindTemplateChild<ContentPresenter>("PART_ContentPresenter");
}
}
}

8
tests/Perspex.Controls.UnitTests/ContentControlTests.cs

@ -217,8 +217,7 @@ namespace Perspex.Controls.UnitTests
target.Content = null;
// Need to call ApplyTemplate on presenter for CollectionChanged to be called.
var presenter = target.GetTemplateChildren().Single(x => x.Name == "contentPresenter");
presenter.ApplyTemplate();
target.Presenter.ApplyTemplate();
Assert.True(called);
}
@ -240,8 +239,7 @@ namespace Perspex.Controls.UnitTests
contentControl.Content = child2;
// Need to call ApplyTemplate on presenter for CollectionChanged to be called.
var presenter = contentControl.GetTemplateChildren().Single(x => x.Name == "contentPresenter");
presenter.ApplyTemplate();
contentControl.Presenter.ApplyTemplate();
Assert.True(called);
}
@ -295,7 +293,7 @@ namespace Perspex.Controls.UnitTests
Background = new Media.SolidColorBrush(0xffffffff),
Child = new ContentPresenter
{
Name = "contentPresenter",
Name = "PART_ContentPresenter",
[~ContentPresenter.ContentProperty] = parent[~ContentControl.ContentProperty],
}
};

2
tests/Perspex.Controls.UnitTests/Primitives/PopupTests.cs

@ -277,7 +277,7 @@ namespace Perspex.Controls.UnitTests.Primitives
{
return new ContentPresenter
{
Name = "contentPresenter",
Name = "PART_ContentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
};
}

2
tests/Perspex.Controls.UnitTests/Utils/HotKeyManagerTests.cs

@ -65,7 +65,7 @@ namespace Perspex.Controls.UnitTests.Utils
{
return new ContentPresenter
{
Name = "contentPresenter",
Name = "PART_ContentPresenter",
[~ContentPresenter.ContentProperty] = parent[~ContentControl.ContentProperty],
};
});

Loading…
Cancel
Save