Browse Source

Lookup property on correct object.

pull/297/head
Steven Kirk 11 years ago
parent
commit
d762913cd5
  1. 4
      src/Markup/Perspex.Markup.Xaml/Binding/XamlTemplateBinding.cs
  2. 22
      src/Perspex.Base/PerspexPropertyRegistry.cs

4
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)
{

22
src/Perspex.Base/PerspexPropertyRegistry.cs

@ -179,6 +179,28 @@ namespace Perspex
return results.FirstOrDefault(x => x.Name == propertyName);
}
/// <summary>
/// Finds a registered property on an object by name.
/// </summary>
/// <param name="o">The object.</param>
/// <param name="name">
/// The property name. If an attached property it should be in the form
/// "OwnerType.PropertyName".
/// </param>
/// <returns>
/// The registered property or null if no matching property found.
/// </returns>
public PerspexProperty FindRegistered(PerspexObject o, string name)
{
return FindRegistered(o.GetType(), name);
}
/// <summary>
/// Returns a type and all its base types.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>The type and all its base types.</returns>
private IEnumerable<string> GetImplementedTypes(Type type)
{
while (type != null)

Loading…
Cancel
Save