Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can call your custom code AFTER calling base.ArrangeOverride() in your window's ArrangeOverride implementation:</p> <pre><code> protected override Size ArrangeOverride(Size arrangeBounds) { Size temp = base.ArrangeOverride(arrangeBounds); // custom code goes here! return temp; } </code></pre> <p>(I tested just now and it works: the custom code is executed after the ArrangeOverride of any child control in the window)</p> <p>EDIT: Follows a tested and working example:</p> <p>In window1.xaml.cs:</p> <pre><code>[...] protected override Size ArrangeOverride(Size arrangeBounds) { Trace.TraceInformation("Window1.ArrangeOverride START"); Size temp = base.ArrangeOverride(arrangeBounds); Trace.TraceInformation("Window1.ArrangeOverride END"); return temp; } [...] </code></pre> <p>In myUserControl.xaml.cs:</p> <pre><code>[...] 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; } [...] </code></pre> <p>In window1.xaml:</p> <pre><code>[...] &lt;local:myUserControl Tag="FirstLevelControl"&gt; &lt;StackPanel&gt; &lt;local:myUserControl Tag="SecondLevelControl_1"&gt; &lt;TextBlock&gt;First&lt;/TextBlock&gt; &lt;/local:myUserControl&gt; &lt;local:myUserControl Tag="SecondLevelControl_2"&gt; &lt;TextBlock&gt;Second&lt;/TextBlock&gt; &lt;/local:myUserControl&gt; &lt;/StackPanel&gt; &lt;/local:myUserControl&gt; [...] </code></pre> <p>And, finally, the output after the execution:</p> <pre><code>[...] 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 [...] </code></pre> <p>This demonstrate that the line of code between <code>temp = base.ArrangeOverride</code> and <code>return temp</code> is always executed AFTER all the code in all nested user controls' ArrangeOverride method. I've not tried to trace the execution of Arrange of built-in controls, but I suppose they have the same behaviour.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload