Getting the attached property “Canvas.Left”

萝らか妹 提交于 2019-12-02 07:11:14

I think this is because Canvas.Left is attached property and to retrieve them try this:

private DependencyProperty GetAttachedProperty(DependencyObject obj, string propertyName, Type ownerType)
{

    foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(obj,
        new Attribute[] { new PropertyFilterAttribute(PropertyFilterOptions.All) }))
    {
        DependencyPropertyDescriptor dpd =
            DependencyPropertyDescriptor.FromProperty(pd);

        if (dpd != null && dpd.IsAttached)
        {
            if (string.Compare(dpd.DependencyProperty.Name, propertyName, StringComparison.CurrentCultureIgnoreCase) == 0 && dpd.DependencyProperty.OwnerType == ownerType)
            {
                return dpd.DependencyProperty;
            }
        }
    }

    return null;
}

Source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!