Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to access actual Height of Elements with Height=Auto
    text
    copied!<p>I have a situation like this:</p> <pre><code>&lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="560"/&gt; &lt;ColumnDefinition Width="250"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;!-- status infos &amp; content start --&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;!-- status infos --&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;!-- status infos --&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;!-- status infos --&gt; &lt;RowDefinition Height="*"/&gt; &lt;!-- content ends --&gt; &lt;/Grid.RowDefinitions&gt; &lt;!-- image a list of custom controls directed to the first or second column on all rows here --&gt; &lt;SomeCustomControl Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Grid.RowSpan="2" /&gt; &lt;/Grid&gt; </code></pre> <p>As you can see I have 2 Columns, the right one is more or less reserved for status information, the left for content. "SomeCustomControl" contains a control so wide it needs to be set to ColumnSpan="2". Notice there are still the status control in the right column. In SomeCustomControl I have something like this:</p> <pre><code>&lt;Grid x:Name="LayoutRoot"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;ColumnDefinition Width="250"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; [...] &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;!-- problem control here --&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;!-- a list of Controls limited to the first column --&gt; &lt;ProblemControl Grid.Column="0" Grid.ColumnSpan="2" /&gt; &lt;/Grid&gt; </code></pre> <p>Now, the first Rows of SomeCustomControl contain controls limited to the first column, then there is a row that contains my ProblemControl. The Height of the status controls is not predetermined and depends on the shown status information. The controls in SomeCustomControl that are limited to the first column also have different heights, that are currently determined automatically through the content.</p> <p>I now have the problem that ProblemControl overlaps with some of my status controls. I tried to calculate the height of my status controls and the limited controls in SomeCustomControl, but as all controls are sized dynamically I can't seem to get correct Heights. The Height of the RowDefinitions all contains Heights of type Auto and value 1, the Heights of the concrete Controls seems to be NaN.</p> <p>Any ideas as to how I can calc the heights or prevent the overlapings in other ways.</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