From c1ba7cc5262f807dc1c511f2ea295a0e2700ee92 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 27 Jul 2015 20:24:20 +0200 Subject: [PATCH] Use interfaces in templates. --- Perspex.Controls/Primitives/TemplatedControl.cs | 4 ++-- Perspex.Controls/Templates/ControlTemplate.cs | 4 ++-- Perspex.Controls/Templates/ControlTemplate`2.cs | 2 +- Perspex.Controls/Templates/DataTemplate`1.cs | 4 ++-- Perspex.Controls/Templates/IControlTemplate.cs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Perspex.Controls/Primitives/TemplatedControl.cs b/Perspex.Controls/Primitives/TemplatedControl.cs index 6e7fe0b822..fefcc808fb 100644 --- a/Perspex.Controls/Primitives/TemplatedControl.cs +++ b/Perspex.Controls/Primitives/TemplatedControl.cs @@ -138,8 +138,8 @@ namespace Perspex.Controls.Primitives this.templateLog.Verbose("Creating control template"); var child = this.Template.Build(this); - this.SetTemplatedParent(child); - this.AddVisualChild(child); + this.SetTemplatedParent((Control)child); + this.AddVisualChild((Visual)child); ((ISetLogicalParent)child).SetParent(this); foreach (var i in this.GetTemplateChildren()) diff --git a/Perspex.Controls/Templates/ControlTemplate.cs b/Perspex.Controls/Templates/ControlTemplate.cs index 50dc546693..ca3fd6704a 100644 --- a/Perspex.Controls/Templates/ControlTemplate.cs +++ b/Perspex.Controls/Templates/ControlTemplate.cs @@ -13,13 +13,13 @@ namespace Perspex.Controls.Templates /// /// A template for a . /// - public class ControlTemplate : FuncTemplate, IControlTemplate + public class ControlTemplate : FuncTemplate, IControlTemplate { /// /// Initializes a new instance of the class. /// /// The build function. - public ControlTemplate(Func build) + public ControlTemplate(Func build) : base(build) { } diff --git a/Perspex.Controls/Templates/ControlTemplate`2.cs b/Perspex.Controls/Templates/ControlTemplate`2.cs index 870cb94673..93e2156338 100644 --- a/Perspex.Controls/Templates/ControlTemplate`2.cs +++ b/Perspex.Controls/Templates/ControlTemplate`2.cs @@ -20,7 +20,7 @@ namespace Perspex.Controls.Templates /// Initializes a new instance of the class. /// /// The build function. - public ControlTemplate(Func build) + public ControlTemplate(Func build) : base(x => build((T)x)) { } diff --git a/Perspex.Controls/Templates/DataTemplate`1.cs b/Perspex.Controls/Templates/DataTemplate`1.cs index d3b0acc7f1..fde2d3926b 100644 --- a/Perspex.Controls/Templates/DataTemplate`1.cs +++ b/Perspex.Controls/Templates/DataTemplate`1.cs @@ -20,7 +20,7 @@ namespace Perspex.Controls.Templates /// /// A function which when passed an object of returns a control. /// - public DataTemplate(Func build) + public DataTemplate(Func build) : base(typeof(T), CastBuild(build)) { } @@ -34,7 +34,7 @@ namespace Perspex.Controls.Templates /// /// A function which when passed an object of returns a control. /// - public DataTemplate(Func match, Func build) + public DataTemplate(Func match, Func build) : base(CastMatch(match), CastBuild(build)) { } diff --git a/Perspex.Controls/Templates/IControlTemplate.cs b/Perspex.Controls/Templates/IControlTemplate.cs index bdd6542efe..61f9023a37 100644 --- a/Perspex.Controls/Templates/IControlTemplate.cs +++ b/Perspex.Controls/Templates/IControlTemplate.cs @@ -12,7 +12,7 @@ namespace Perspex.Controls.Templates /// /// Interface representing a template used to build a . /// - public interface IControlTemplate : ITemplate + public interface IControlTemplate : ITemplate { } } \ No newline at end of file