Now i want to get the actualWidth and actualHeight of Grid fLand in constructor of object Land1. The actual width/height is in constructor 0, but if i add some MouseLeftButtonUp on gLand, and there read actual width/height, the values are correct.
So i want to get this two values automatic at some time after create. How to do this. I don't want to add some timer and then check values. There must be a better idea.
I believe, that immediatelly after creating the UserControl the grid isn't stretch yet, so the actual width/height is 0. Then some painting is done, and after that i can get dimension.
forci
Member
351 Points
275 Posts
Get ActualWidth and ActualHeight in constructor
Oct 13, 2008 08:38 AM | LINK
I have this xaml:
<UserControl x:Class="ClientLibrary1.Controls.Land1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="gLand" Background="Yellow">
</Grid>
</UserControl>
Now i want to get the actualWidth and actualHeight of Grid fLand in constructor of object Land1. The actual width/height is in constructor 0, but if i add some MouseLeftButtonUp on gLand, and there read actual width/height, the values are correct.
So i want to get this two values automatic at some time after create. How to do this. I don't want to add some timer and then check values. There must be a better idea.
I believe, that immediatelly after creating the UserControl the grid isn't stretch yet, so the actual width/height is 0. Then some painting is done, and after that i can get dimension.
Any idea?
Sergey.Lutay
Star
13559 Points
2381 Posts
Re: Get ActualWidth and ActualHeight in constructor
Oct 13, 2008 10:04 AM | LINK
Hi,
Try to use LayoutUpdated event of UserControl class if you need to know actual width/height periodically.
Silverlight 2
Twitter
Sincerely,
Sergii Lutai
MCT, MCPD, Head of Dev. Dept at DCT
forci
Member
351 Points
275 Posts
Re: Re: Get ActualWidth and ActualHeight in constructor
Oct 14, 2008 07:43 AM | LINK
Thanks