Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image out of the grid

Tags:

wpf

I don't know why Image crosses grid right border, how to repair it? Code looks like that:

    <Grid>
        <Grid Name="grid1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="260" />
                <ColumnDefinition Width="640" />
            </Grid.ColumnDefinitions>
            <Image Grid.Column="1" HorizontalAlignment="Stretch" Margin="0" Name="image1" Stretch="Fill" VerticalAlignment="Stretch" Source="path.png"/>
            <ListView Height="361" HorizontalAlignment="Left" Margin="10,10,0,0" Name="listView1" VerticalAlignment="Top" Width="240" ItemsSource="{Binding}" />
            <Button Content="Add New Gesture" Height="39" HorizontalAlignment="Left" Margin="10,387,0,0" Name="button1" VerticalAlignment="Top" Width="112" Click="button1_Click" />
            <Button Content="Delete" Height="39" HorizontalAlignment="Left" Margin="191,387,0,0" Name="button2" VerticalAlignment="Top" Width="59" />
            <Button Content="Modify" Height="39" HorizontalAlignment="Left" Margin="128,387,0,0" Name="button3" VerticalAlignment="Top" Width="57" />
        </Grid>
    </Grid>
like image 294
Małgorzata Podlecka Avatar asked Nov 03 '22 11:11

Małgorzata Podlecka


1 Answers

This looks like an effect of the fixed widths you have set (Maybe the sum of your fixed column widths is greater than the fixed window width?) That would cause the grid cell (and image) to go out of the view.

If you want the image to fill the entire space remaining in the window, change your second ColumnDefinition width to "*" instead of 640:

<ColumnDefinition Width="*" />
like image 53
WildCrustacean Avatar answered Jan 04 '23 14:01

WildCrustacean