**已关闭。**此问题需要debugging details。当前不接受答案。
编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
2天前关闭。
Improve this question
我有一个自定义面板Foo,它有另一个自定义面板栏作为它的孩子。
当用户移动鼠标时,Foo调用Bar上的方法'Update',使bar将其renderTransform设置为不同的值。
当我这样做的时候,Bar中的ArrangeOverride方法被调用了(不是在Foo上),我很困惑为什么会发生这种情况,因为不需要进行布局更改。这是故意的还是某种bug?
1条答案
按热度按时间yyhrrdl81#
如果你看一下UIElement.Rendertransform的参考源代码。
https://referencesource.microsoft.com/#q=rendertransform
更改已进行测量排列的uireelement的属性将在该uireelement上调用InvalidateArrange。
这将导致安排被调用。
我们对您的代码了解不够,无法提出具体的更好方法,但这不是问题所在。您需要确保更改了子属性,或者确保调用ArrangeOverride无关紧要,或者(我猜不太实用)在更改之前避免父面板中的布局过程。
也许你可以在Bar中添加一个IgnoreArrange标志。默认为false。在改变变换之前设置为true,之后设置为false,如果为true,则返回ArrangeOverride。
底线是,这是上面的代码导致你所看到的。