custom attached property not found

我只是一个虾纸丫 提交于 2019-12-02 09:59:51

The third parameter ownerType of the RegisterAttached method must be

The owner type that is registering the dependency property

not the type of the object where you want to set the property.

So your declaration should look like this:

DependencyProperty^ PivotProperties::_menuForegroundProperty =
    DependencyProperty::RegisterAttached(
        "MenuForeground",
        Windows::UI::Color::typeid,
        PivotProperties::typeid, // here
        ref new PropertyMetadata(false));

Please note also that it is not necessary that your PivotProperties class derives from DependencyObject, as long as it only declares attached properties.

You may also consider using Windows.UI.Xaml.Media.Brush as property type to make it conforming with other properties like Background and Foreground.

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