我正在尝试将横向和纵向图像绑定到网格控件。横向图像已正确加载,但在加载纵向图像时我遇到了问题。它们的底部被切断(溢出),因此网格行无法加载完整高度的图像。我尝试使用Height="Auto"
or设置 Row 属性,Height="*"
但这不起作用。这是我的 XAML:
<ItemsControl ItemsSource="{Binding ItemsPrasanja}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Name="txtPrasanje"
Grid.Row="0"
Text="{Binding Tekst}"
TextWrapping="Wrap" />
<Image Name="imgPrasanje"
Grid.Row="1"
Source="{Binding Slika}"
Margin="0,5,0,0" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
如何在不手动设置Width
或设置Height
网格或图像控件的情况下解决此问题?
PS ItemsControl 是另一个 Grid 控件的一部分。它填充了我设置的 (Grid.Row="0")Height="*"
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
我已经尝试了所有Stretch
属性,但没有任何效果。图像仍然被裁剪。