How can my control size be NaN when it is actually displayed?

I have a grid that contains an image in one of its columns. The image itself does not have a width or height, but its size is controlled using the ColumnDefinition set. From this, I would assume that the width and height are actually set on the image controller, but when I try to associate another element with its width and height, it does not work. When debugging, it turns out that the value of Image.Height and Image.Width is NaN. What for?

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="350"></ColumnDefinition>
        <ColumnDefinition Width="*"></ColumnDefinition>
        <ColumnDefinition Width="10"></ColumnDefinition>
        <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>

    <Grid Grid.Column="0">
        <Image x:Name="_image" Source="image.jpg"></Image>
    </Grid>

 </Grid>
+3
source share
2 answers

Are you looking for .RenderSize or .ActualSize

+3
source

Debugging WHEN?

NAN , " , " "undefined". , NAN .

, , , "NAN". ;)

+1

Source: https://habr.com/ru/post/1736097/


All Articles