From 25fa7ddc6af1be1b766ba633f09fda6bda4c6727 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 24 Oct 2015 01:15:18 +0200 Subject: [PATCH] Added Carousel and CheckBox XAML styles. --- samples/XamlTestApplicationPcl/Button.paml | 3 +- samples/XamlTestApplicationPcl/Carousel.paml | 16 ++++++++++ samples/XamlTestApplicationPcl/CheckBox.paml | 30 +++++++++++++++++++ .../XamlTestApplicationPcl/XamlTestApp.paml | 2 ++ .../XamlTestApplicationPcl.csproj | 6 ++++ .../Templates/ControlTemplate.cs | 2 -- src/Perspex.Controls/ContentControl.cs | 2 +- .../ContentControlTests.cs | 8 ++--- .../Primitives/PopupTests.cs | 2 +- .../Utils/HotKeyManagerTests.cs | 2 +- 10 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 samples/XamlTestApplicationPcl/Carousel.paml create mode 100644 samples/XamlTestApplicationPcl/CheckBox.paml diff --git a/samples/XamlTestApplicationPcl/Button.paml b/samples/XamlTestApplicationPcl/Button.paml index f1618cab37..256ac94df9 100644 --- a/samples/XamlTestApplicationPcl/Button.paml +++ b/samples/XamlTestApplicationPcl/Button.paml @@ -7,13 +7,14 @@ - + diff --git a/samples/XamlTestApplicationPcl/Carousel.paml b/samples/XamlTestApplicationPcl/Carousel.paml new file mode 100644 index 0000000000..8c0c87143c --- /dev/null +++ b/samples/XamlTestApplicationPcl/Carousel.paml @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/samples/XamlTestApplicationPcl/CheckBox.paml b/samples/XamlTestApplicationPcl/CheckBox.paml new file mode 100644 index 0000000000..66451feb9c --- /dev/null +++ b/samples/XamlTestApplicationPcl/CheckBox.paml @@ -0,0 +1,30 @@ + + + \ No newline at end of file diff --git a/samples/XamlTestApplicationPcl/XamlTestApp.paml b/samples/XamlTestApplicationPcl/XamlTestApp.paml index bf3dfb00aa..a06ad25a6e 100644 --- a/samples/XamlTestApplicationPcl/XamlTestApp.paml +++ b/samples/XamlTestApplicationPcl/XamlTestApp.paml @@ -3,5 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + + \ No newline at end of file diff --git a/samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj b/samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj index 2bd010854f..5d73328952 100644 --- a/samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj +++ b/samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj @@ -123,6 +123,12 @@ Designer + + Designer + + + Designer + Designer diff --git a/src/Markup/Perspex.Markup.Xaml/Templates/ControlTemplate.cs b/src/Markup/Perspex.Markup.Xaml/Templates/ControlTemplate.cs index 0e7e8bbdd3..1136c63858 100644 --- a/src/Markup/Perspex.Markup.Xaml/Templates/ControlTemplate.cs +++ b/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; } diff --git a/src/Perspex.Controls/ContentControl.cs b/src/Perspex.Controls/ContentControl.cs index 5bfbfdfa77..f051b31f65 100644 --- a/src/Perspex.Controls/ContentControl.cs +++ b/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"); + Presenter = this.FindTemplateChild("PART_ContentPresenter"); } } } diff --git a/tests/Perspex.Controls.UnitTests/ContentControlTests.cs b/tests/Perspex.Controls.UnitTests/ContentControlTests.cs index 4c62f8b812..ca47bf8571 100644 --- a/tests/Perspex.Controls.UnitTests/ContentControlTests.cs +++ b/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], } }; diff --git a/tests/Perspex.Controls.UnitTests/Primitives/PopupTests.cs b/tests/Perspex.Controls.UnitTests/Primitives/PopupTests.cs index 7c2db5e86a..28da8d75e3 100644 --- a/tests/Perspex.Controls.UnitTests/Primitives/PopupTests.cs +++ b/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], }; } diff --git a/tests/Perspex.Controls.UnitTests/Utils/HotKeyManagerTests.cs b/tests/Perspex.Controls.UnitTests/Utils/HotKeyManagerTests.cs index 43a32199d4..40949e624a 100644 --- a/tests/Perspex.Controls.UnitTests/Utils/HotKeyManagerTests.cs +++ b/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], }; });