You can call your custom code AFTER calling the .ArrangeOverride () database in your ArrangeOverride window:
protected override Size ArrangeOverride(Size arrangeBounds) { Size temp = base.ArrangeOverride(arrangeBounds);
(I tested just now, and it works: custom code is executed after ArrangeOverride of any child control in the window)
EDIT: Running a proven and working example:
In the window 1.xaml.cs:
[...] protected override Size ArrangeOverride(Size arrangeBounds) { Trace.TraceInformation("Window1.ArrangeOverride START"); Size temp = base.ArrangeOverride(arrangeBounds); Trace.TraceInformation("Window1.ArrangeOverride END"); return temp; } [...]
In myUserControl.xaml.cs:
[...] protected override Size ArrangeOverride(Size arrangeBounds) { Trace.TraceInformation("{0}.ArrangeOverride START", Tag); Size s = base.ArrangeOverride(arrangeBounds); Trace.TraceInformation("{0}.ArrangeOverride END", Tag); return s; } [...]
In window 1.xaml:
[...] <local:myUserControl Tag="FirstLevelControl"> <StackPanel> <local:myUserControl Tag="SecondLevelControl_1"> <TextBlock>First</TextBlock> </local:myUserControl> <local:myUserControl Tag="SecondLevelControl_2"> <TextBlock>Second</TextBlock> </local:myUserControl> </StackPanel> </local:myUserControl> [...]
And finally, the result after execution:
[...] Test.vshost.exe Information: 0 : Window1.ArrangeOverride START Test.vshost.exe Information: 0 : FirstLevelControl.ArrangeOverride START Test.vshost.exe Information: 0 : SecondLevelControl_1.ArrangeOverride START Test.vshost.exe Information: 0 : SecondLevelControl_1.ArrangeOverride END Test.vshost.exe Information: 0 : SecondLevelControl_2.ArrangeOverride START Test.vshost.exe Information: 0 : SecondLevelControl_2.ArrangeOverride END Test.vshost.exe Information: 0 : FirstLevelControl.ArrangeOverride END Test.vshost.exe Information: 0 : Window1.ArrangeOverride END [...]
This demonstrates that a line of code between temp = base.ArrangeOverride and return temp always executed AFTER all the code in all ArrangeOverride methods of nested user controls. I did not try to track the execution of Arrange inline controls, but I believe that they have the same behavior.
Bertupg
source share