Get height of content items

91 views Asked by At

Cannot determine Height or ActualHeight of the following:

<Border Grid.Column="1" x:Name="statusCounter"
        BorderThickness="1"
        BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
    <StackPanel Orientation="Horizontal" Margin="5">
        <TextBlock Text="Loading " x:Name="txtLoading" />
        <!-- more TextBlock's -->
    </StackPanel>
</Border>

txtLoading gives a height of ~12 statusCounter the Border has an ActualHeight of 2.

The desired result should be 24 for statusCounter:

  • txtLoading is 12
  • Border is 2
  • Margin is 10 (5 times 2 for the top and bottom)

The above Border control is placed in a Grid that is to be animated to disappear when another control finishes loading.

Should I be wrapping the above in a different container to get the actual height of the whole?

1

There are 1 answers

1
Kobe On

ElementName=self reference to what if this view has a viewModel you can set as this Text="{Binding Items.Count}" you can use Canvas instead of grid