I change the layout dynamically at runtime.
There was a task to rewrite the Attached Property values from the element being removed to the embedding element.
I get all the assigned properties using the GetLocalValueEnumerator() method.
But now I need to somehow select only the Attached property from the general DependecyProperty list.
I read a good explanation about the differences between them here: What's the difference between a dependency property and an attached property in WPF?
But I did not understand how to use this information for my purpose.
Updating
According to the comments from @Clemens, I created such a method. So far it works acceptable for my solution. Perhaps in the future there will be some nuances. And then I will think about how to eliminate them.
private static bool IsDependecyProperty(Type ownerTYpe, DependencyProperty property)
{
if (typeof(DependencyObject).IsAssignableFrom(property.OwnerType) &&
property.OwnerType.IsAssignableFrom(ownerTYpe))
{
string propName = property.Name;
return ownerTYpe.GetProperty(propName) != null;
}
return false;
}