此代码来自Kinect for Windows开发人员工具包2.0中提供的示例。我希望图片覆盖瓷砖,但它不起作用。
这是Xaml代码:
<ItemsControl Grid.Row="0" Name="itemsControl" ItemTemplate="{StaticResource Kinect350x350ItemTemplate}" Button.Click="ButtonClick
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel VerticalAlignment="Center" Orientation="Vertical" Margin="75,0,75,0" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
这是我的StaticResource Kinect350x350ItemTemplate
<DataTemplate x:Key="Kinect350x350ItemTemplate">
<Button Margin="5" Style="{StaticResource KinectTileButton}">
<Grid HorizontalAlignment="Left" Width="350" Height="350">
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
</Border>
<StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/>
<TextBlock Text="{Binding Subtitle}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
</StackPanel>
</Grid>
</Button>
</DataTemplate>
据我所知,这一行没有显示我的图像:
<Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
以下是数据模型:
private static Uri darkGrayImage = new Uri("thumbs/DarkGray.png", UriKind.Relative);
private static Uri mediumGrayImage = new Uri("thumbs/mediumGray.png", UriKind.Relative);
private static Uri lightGrayImage = new Uri("thumbs/lightGray.png", UriKind.Relative);
private static Uri AUMImage = new Uri("thumbs/aum.jpg", UriKind.Relative);
public KuwaitDataSource()
{
string itemContent = string.Format(
CultureInfo.CurrentCulture,
"Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}",
"Bla-Bla-Bla");
var group1 = new KuwaitDataCollection(
"Group-1",
"Group Title: 3",
"Group Subtitle: 3",
KuwaitDataSource.AUMImage,
"Group Description: Some text here.");
group1.Items.Add(
new SampleDataItem(
"Group-1-Item-1",
"Egaila",
"Egaila is a quite city to live. It has a great university AUM and big shopping centers.",
KuwaitDataSource.AUMImage,
"A map of Egaila, enabling scrolling and zooming.",
itemContent,
group1,
typeof(Egaila)));
this.AllGroups.Add(group1);
}
在输出中我只有ListViewItemPlaceholderBackgroundThemeBrush,没有图像...我错过了什么?