Knowing if a DependencyProperty has not been set in XAML

前端 未结 1 1432
小蘑菇
小蘑菇 2020-12-29 15:17

I have a control, which exposes a DP called PlacementTarget (it\'s bound to a child Popup FWIW).

What I want to do is if PlacementTarget is not set in XAML, then (

1条回答
  •  佛祖请我去吃肉
    2020-12-29 15:18

    You don't need an extra placementTargetIsSet field and hence no PropertyChangedCallback.

    In order to find out if a value has been set for the PlacementTarget property, you could just call the ReadLocalValue method and test if it returns DependencyProperty.UnsetValue:

    bool placementTargetIsSet =
        ReadLocalValue(PlacementTargetProperty) != DependencyProperty.UnsetValue;
    

    0 讨论(0)
提交回复
热议问题