Reputation: 2593
I have two borders in a winwdow, the first one contains a listbox which has size set through margins. So I can change the window size--->the border changes---> the listbox changes. I'd like to know what it's width is but the width property reports Nan while the actualWidth report 0.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border x:Name="Border1" BorderBrush="Gainsboro" BorderThickness="5" CornerRadius="8,8,3,3" Margin="10,10,168.8,10.4" >
<ListBox x:Name="lbButtons" Background="{x:Null}" BorderBrush="{x:Null}" Height="338" Margin="0,0,0.4,0"/>
</Border>
<Border x:Name="Border2" BorderBrush="Gainsboro" BorderThickness="5" CornerRadius="8,8,3,3" Grid.ColumnSpan="2" Margin="263,10,9.2,10" />
</Grid>
This is something valid for each control: how to know its present size when it's not specified? thanx
Upvotes: 0
Views: 80
Reputation: 937
It is possible that the component is not yet displayed at the point where you get its size. You can get the right actualWidth in the loaded event of the object.
Upvotes: 2