共用方式為


Image and text (list file) template (XAML)

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

Use this item template with a GridView to display a collection of files with an image and text.

This example shows the image gallery DataTemplate and a GridView that uses the template.

<DataTemplate x:Key="ImageTextListFileTemplate">          
    <StackPanel Orientation="Horizontal" Width="300" Height="70">
        <Border Height="40" Width="40" Margin="10,10,0,10">
            <Image Source="/SampleImage.png" Stretch="UniformToFill"/>
        </Border>
        <StackPanel Orientation="Vertical" VerticalAlignment="Top" Margin="0,10,0,0">
            <TextBlock Text="Ay lorem ipsum dolor sit amet" Margin="10,0,0,0" 
                       Width="180" Height="20" HorizontalAlignment="Left" 
                       TextTrimming="WordEllipsis" TextWrapping="Wrap"/>
            <TextBlock Text="Consecutetur adipiscing elit sit Quisque venenatis lacus" 
                       Margin="10,2,0,0" Width="180" Height="42" 
                       TextTrimming="WordEllipsis" TextWrapping="Wrap" 
                       HorizontalAlignment="Left" Opacity="0.49"/>                        
         </StackPanel>
    </StackPanel>             
</DataTemplate>
<GridView x:Name="ImageTextListFileGrid" 
          VerticalAlignment="Stretch" HorizontalAlignment="Left" 
          CanReorderItems="True" CanDragItems="True" 
          ItemTemplate="{StaticResource ImageTextListFileTemplate}">                        
    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsWrapGrid MaximumRowsOrColumns="6"/>                      
          </ItemsPanelTemplate>
    </GridView.ItemsPanel>
</GridView>