【发布时间】:2013-08-11 01:21:56
【问题描述】:
我正在尝试将横向和纵向图像绑定到网格控件。横向图像已正确加载,但在加载纵向图像时我遇到了问题。它们的底部被切断(溢出),因此网格行无法加载完整高度的图像。我尝试使用 Height="Auto" 或 Height="*" 设置 Row 属性,但这不起作用。 这是我的 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>
如何在不手动设置网格或图像控件的宽度或高度的情况下解决此问题?
附: ItemsControl 是另一个 Grid 控件的一部分。它填充了我设置为 Height=" * "
的 (Grid.Row="0") <Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
【问题讨论】:
-
试用要在 XAML 中设置的图像拉伸属性。
-
我已经尝试过使用 Stretch="None"、Stretch="UniformToFill" 和 Stretch="Fill" 但没有效果。 Stretch="Uniform" 默认设置。
标签: c# image windows-phone-7 windows-phone-8 windows-phone