From d762913cd58a7c0063697d1457f05acd8905c1a9 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 19 Oct 2015 19:07:47 +0200 Subject: [PATCH] Lookup property on correct object. --- .../Binding/XamlTemplateBinding.cs | 4 +++- src/Perspex.Base/PerspexPropertyRegistry.cs | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Markup/Perspex.Markup.Xaml/Binding/XamlTemplateBinding.cs b/src/Markup/Perspex.Markup.Xaml/Binding/XamlTemplateBinding.cs index 84794386a6..6a5fdf36a6 100644 --- a/src/Markup/Perspex.Markup.Xaml/Binding/XamlTemplateBinding.cs +++ b/src/Markup/Perspex.Markup.Xaml/Binding/XamlTemplateBinding.cs @@ -40,7 +40,9 @@ namespace Perspex.Markup.Xaml.Binding PerspexProperty targetProperty, PerspexObject templatedParent) { - var sourceProperty = PerspexPropertyRegistry.Instance.FindRegistered(instance.GetType(), SourcePropertyPath); + var sourceProperty = PerspexPropertyRegistry.Instance.FindRegistered( + templatedParent, + SourcePropertyPath); if (sourceProperty == null) { diff --git a/src/Perspex.Base/PerspexPropertyRegistry.cs b/src/Perspex.Base/PerspexPropertyRegistry.cs index 2c388131fa..85f9e275b1 100644 --- a/src/Perspex.Base/PerspexPropertyRegistry.cs +++ b/src/Perspex.Base/PerspexPropertyRegistry.cs @@ -179,6 +179,28 @@ namespace Perspex return results.FirstOrDefault(x => x.Name == propertyName); } + + /// + /// Finds a registered property on an object by name. + /// + /// The object. + /// + /// The property name. If an attached property it should be in the form + /// "OwnerType.PropertyName". + /// + /// + /// The registered property or null if no matching property found. + /// + public PerspexProperty FindRegistered(PerspexObject o, string name) + { + return FindRegistered(o.GetType(), name); + } + + /// + /// Returns a type and all its base types. + /// + /// The type. + /// The type and all its base types. private IEnumerable GetImplementedTypes(Type type) { while (type != null)