ElementName vs. RelativeResource?

前端 未结 3 966
别跟我提以往
别跟我提以往 2020-12-31 03:21

What of the following TextBlocks\' Bindings costs more performance:



        
3条回答
  •  余生分开走
    2020-12-31 03:41

    In general the ElementName should be used when possible.

    The given example and benchmark example is quite simple. In real world examples the elements have a larger visual tree and the FindAncestor binding must traverse a lot more elements in order to find the element.

    I gained SECONDS by changing some FindAncestor bindings to ElementName bindings in a real world application.

    IMHO the ElementName binding is more readable, too.

提交回复
热议问题