Reputation: 51
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>
Upvotes: 5
Views: 433
Reputation: 66
EDIT: It turns out this is wrong and it is not a viable solution. Sorry
Ok, so it is really unclear what exactly is your problem. If you provide some more details, people will be able to help you more easily.
From what I can understand (and this might completely wrong), by saying that the image "crosses grid right border" you mean that the image should only show in one column, but it 'overlfows' into the next column.
This can be avoided by adding the following attribute to the Image control:
Grid.ColumnSpan="1"
So it will be:
<Image Grid.Column="1" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" Margin="0" Name="image1" Stretch="Fill" VerticalAlignment="Stretch" Source="path.png"/>
This will prevent the image from overflowing into other columns, and constrain to the one it is positioned in. As i said before I'm not completely sure I understand your problem, but if you provide some more detail I will gladly try to revise my answer to better help you. Right now though, this is the best I can do.
Upvotes: 0
Reputation: 5966
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="*" />
Upvotes: 2