tags:

views:

403

answers:

3

I have a custom Panel which upon resizing has its LayoutUpdated event and ArrangeOverride called twice.

So initially MeasureOverride and ArrangeOverride do their thing once upon open of the client window. Then, if I maximize the window each are called twice. The Available and Final Sizes respectively are not different between each iteration so I'm not sure what's initiating this.

Is there a way to determine the cause of the Invalidation?

A: 

I would say the easiest way is setting a breakpoint for each method and observing the call stack. You will be able to see what happened before your method was called.

Denis Vuyka
I'm not going to get a stack trace for that which invalidates the control.
Ryan Cromwell
+1  A: 

I think that it is called twice because the Height and Width changes. I think that both of those properties affect Measure and thus there is a layout pass for each one.

Pavel
A: 

Is there a way to determine the cause of the Invalidation?

Invalidation usually is caused by a change of a DependencyProperty which among it's FrameworkPropertyMetadataOptions has flags AffectsMeasure/AffectsOverride.

As Pavel already said - it's likely that invalidation fires for both changes in Width and Height.

Anyway, you shouldn't rely on the number of those invalidations.

archimed7592