I am using dynamic marking of area “Grid”
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<!--This Grid-->
<Grid Grid.Column="0" Name="gridImage" SizeChanged="gridImage_SizeChanged">
<Image Name="image" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Grid>
In my code I am drawing image pixel-by-pixel depending on size of “Grid” which contains this image. How can I read the size of “Grid” area in code?
Properties gridImage->Width and gridImage->Height lets me set values but not get them.
gridImage->Width = 100;//OK
gridImage->Height = 100;//OK
int width = gridImage->Width;//return -2 147 483 648
int height = gridImage->Height;//return -2 147 483 648
If I use SizeChanged event for Grid area then I can read size by using this code
void MainPage::gridImage_SizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e)
{
Size size = e->NewSize;
int width = size.Width;//OK
int height= size.Height;//OK
}
But this event becomes available only after changing of image object, it means that that becomes available after then I need it.
Use the ActualWidth and ActualHeight properties to get the actual width and height in pixels, respectively. Unlike the Height, Width, MinHeight, MinWidth, MaxHeight and MaxWidth, they actually contain the height and width.