我的GridView
有以下DataTemplate <DataTemplate x:Key="GridViewItemTemplate">
<Grid Margin="5,10" MaxWidth="80">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Vendor image-->
<toolkitControls:RoundImageEx IsCacheEnabled="True" PlaceholderSource="/Assets/Samples/AnotherSampleImage.png" PlaceholderStretch="Uniform" Source="/Assets/Samples/SampleImage.png" Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Row="1" Padding="0,5,0,0" Text="{Binding NameEn}" HorizontalAlignment="Center" TextWrapping="Wrap" FontSize="{StaticResource SmallTextSize}"/>
</Grid>
</DataTemplate>
我在这里使用来自UWP社区工具包的RoundImageEx
控件。问题是Image和ImagePlaceholder都没有显示。
我尝试过使用工具包中的ImageEx
控件,效果很好。
GridView在DataTemplate中使用ImageEx(它工作得很好)
GridView在DateTemplate中使用RoundImageEx(图像未显示)
这是某种错误还是我做错了什么?
答案 0 :(得分:2)
为HorizontalAlignment
控件设置VerticalAlignment
和Stretch
为RoundImageEx
代码示例
<toolkitControls:RoundImageEx IsCacheEnabled="True" PlaceholderSource="/Assets/Samples/AnotherSampleImage.png"
PlaceholderStretch="Uniform" Source="/Assets/Samples/SampleImage.png" Stretch="Uniform"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
为Width
控件设置Height
和RoundImageEx
代码示例
<toolkitControls:RoundImageEx IsCacheEnabled="True" PlaceholderSource="/Assets/Samples/AnotherSampleImage.png"
PlaceholderStretch="Uniform" Source="/Assets/Samples/SampleImage.png" Stretch="Uniform"
Width="100" Height="100"/>