Skip to content

Commit

Permalink
Fix Property Finding if ComponentType!=Component.GetType() for Exampl…
Browse files Browse the repository at this point in the history
…e on WindowClone.

Maybe we need to do the same for Events? And maybe cache the Properties for a Type? (Not for a Instance!)
  • Loading branch information
jogibear9988 committed Oct 31, 2014
1 parent f72e6b8 commit f9780ed
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,11 @@ static XamlPropertyInfo GetDefaultProperty(Type elementType)

internal static XamlPropertyInfo FindProperty(object elementInstance, Type propertyType, string propertyName)
{
PropertyDescriptorCollection properties;
if (elementInstance != null) {
properties = TypeDescriptor.GetProperties(elementInstance);
} else {
properties = TypeDescriptor.GetProperties(propertyType);
}
PropertyDescriptor propertyInfo = properties[propertyName];
PropertyDescriptor propertyInfo = TypeDescriptor.GetProperties(propertyType)[propertyName];

if (propertyInfo == null && elementInstance != null)
propertyInfo = TypeDescriptor.GetProperties(elementInstance).OfType<DependencyPropertyDescriptor>().FirstOrDefault(x => x.IsAttached && x.Name == propertyName);

if (propertyInfo != null) {
return new XamlNormalPropertyInfo(propertyInfo);
} else {
Expand Down

0 comments on commit f9780ed

Please sign in to comment.