UWP社区工具包RoundImageEx图像未显示

时间:2017-08-06 07:41:54

标签: xaml uwp win-universal-app uwp-xaml windows-community-toolkit

我的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 using ImageEx in the DataTemplate (it works just fine)

GridView在DateTemplate中使用RoundImageEx(图像未显示) GridView using RoundImageEx in the DateTemplate (images not showing)

这是某种错误还是我做错了什么?

1 个答案:

答案 0 :(得分:2)

方法1:

HorizontalAlignment控件设置VerticalAlignmentStretchRoundImageEx

代码示例

<toolkitControls:RoundImageEx IsCacheEnabled="True" PlaceholderSource="/Assets/Samples/AnotherSampleImage.png" 
                              PlaceholderStretch="Uniform" Source="/Assets/Samples/SampleImage.png" Stretch="Uniform" 
                              HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

方法2:

Width控件设置HeightRoundImageEx

代码示例

<toolkitControls:RoundImageEx IsCacheEnabled="True" PlaceholderSource="/Assets/Samples/AnotherSampleImage.png" 
                              PlaceholderStretch="Uniform" Source="/Assets/Samples/SampleImage.png" Stretch="Uniform"
                              Width="100" Height="100"/>