diff --git a/Perspex/Styling/Match.cs b/Perspex/Styling/Match.cs index a9851c0c4c..c55c263d28 100644 --- a/Perspex/Styling/Match.cs +++ b/Perspex/Styling/Match.cs @@ -20,6 +20,14 @@ namespace Perspex.Styling this.Observables = new List>(); } + public Match(Match source) + { + this.Control = source.Control; + this.InTemplate = source.InTemplate; + this.Observables = source.Observables; + this.SelectorString = SelectorString; + } + public IStyleable Control { get; diff --git a/Perspex/Styling/Selectors.cs b/Perspex/Styling/Selectors.cs index 10041af8f1..ec82b196ce 100644 --- a/Perspex/Styling/Selectors.cs +++ b/Perspex/Styling/Selectors.cs @@ -64,9 +64,12 @@ namespace Perspex.Styling Contract.Requires(match != null); match.Observables.Add(Observable.Return(match.Control.TemplatedParent is T)); - match.InTemplate = true; match.SelectorString += '%' + typeof(T).Name; - return match; + + return new Match(match) + { + InTemplate = true, + }; } public static Match OfType(this Match match) where T : IStyleable