xamlbindinguwpvisualstatesxbind

Binding to ElementName depends on binding order


I created simple StateTrigger to bind to FrameworkElement Width property. There are three dependency properties: MinValue, MaxValue and Element. They types are double, double and FrameworkElement accordingly.

And I noticed that depending on binding order it may or may not work.

This works fine.

<local:ElementWidthTrigger MaxValue="1000"
                           MinValue="800"
                           Element="{Binding ElementName=LayoutRoot}" />

And this is not.

<local:ElementWidthTrigger Element="{Binding ElementName=LayoutRoot}"
                           MaxValue="1000"
                           MinValue="800" />

Noticed that only difference in this two samples is Element property binding order.

In ElementWidthTrigger there is property changed callback for each dependency property. And when Element at the very top it's callback never called no matter what.

x:Bind solves this issue no matter what order is in use but a question remains. Can anyone explain why Element property is failing to bind depending on binding order?

Running on Windows 10 1803 build 17134.320.

Working example project can be found here.


Solution

  • Thank you reporting this issue and providing a solid repro project - this is a platform bug. I have logged it in our database and assigned to the right team. Thanks again!