C# Silverlight 5 Pivotviewer:未显示任何图像

C# Silverlight 5 Pivotviewer:未显示任何图像,c#,silverlight,pivotviewer,C#,Silverlight,Pivotviewer,我正在使用Visual Studio 2013和Silverlight 5 Pivotviewer。几年前,我已经用前一个版本做了一些Pivotviewer的工作,它通过Excel插件工具工作得很好。现在我正试图用代码和版本5创建一个pivotviewer 我举了一个互联网上的例子,它展示了一种生日书。该示例中的PivotViewerItemTemplate是一个带有文本框的简单边框。一切正常,但我想在PivotViewerItemTemplate中包含一个图像文件,其中源标记绑定到一个字符串。

我正在使用Visual Studio 2013和Silverlight 5 Pivotviewer。几年前,我已经用前一个版本做了一些Pivotviewer的工作,它通过Excel插件工具工作得很好。现在我正试图用代码和版本5创建一个pivotviewer

我举了一个互联网上的例子,它展示了一种生日书。该示例中的PivotViewerItemTemplate是一个带有文本框的简单边框。一切正常,但我想在PivotViewerItemTemplate中包含一个图像文件,其中源标记绑定到一个字符串。不知何故,直到我通过工具箱手动将另一张图片放在窗口的任何地方,我才得到任何图片。现在,pivotviewer开始为它通过绑定获得的所有对象显示该图像。我调试了一下,发现绑定对所有人都起到了正确的作用

Mainpage.xaml

正如您在底部看到的,我放置了两个图像,然后pivotviewer开始接受图像bild4和bild。所以布拉德和洛基现在正在展示这些图像。从底部删除两条图像线后,pivotviewer不再显示任何内容,只显示边框及其背景色

MainPage.xaml.cs


我猜ItemTemplate标记中的xaml代码中有错误,但是在哪里呢?bild 120x120、bild3 485x485和bild4 120x120的特性。图像包含在项目的“图像”文件夹中,构建操作是资源。

有什么想法吗?在此期间,我继续使用文本框,它们工作得很好。但仍然没有图像。好的,问题解决了。源标记缺少一条斜线。所以Source=/images/Bild.png完成了这项工作。
 <UserControl x:Class="PivotViewer5.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:pv="clr-namespace:System.Windows.Controls.Pivot;assembly=System.Windows.Controls.Pivot"
    xmlns:local="clr-namespace:PivotViewer5"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">


    <Grid x:Name="LayoutRoot" Background="White">
        <pv:PivotViewer x:Name="pivotviewer" ItemsSource="{Binding}">
            <pv:PivotViewer.PivotProperties>
                <pv:PivotViewerStringProperty Id="Name" Options="CanFilter" DisplayName="Name" Binding="{Binding Name}" />
                <pv:PivotViewerNumericProperty Id="Age" Options="CanFilter" DisplayName="Age" Binding="{Binding Age}" />
                <pv:PivotViewerDateTimeProperty Id="Birthday" Options="CanFilter" DisplayName="Birthday" Binding="{Binding Birthday}" />
            </pv:PivotViewer.PivotProperties>
            <pv:PivotViewer.ItemTemplates>
                <pv:PivotViewerItemTemplate MaxWidth="800">
                    <Border Width="120" Height="120" Background="DarkSlateBlue">
                        <Image Source="{Binding ImageName}" Width="120" Height="120"/>
                    </Border>
                </pv:PivotViewerItemTemplate>
                <pv:PivotViewerItemTemplate>
                    <Border Width="120" Height="120" Background="Blue">
                        <Image Source="{Binding ImageName}" Width="120" Height="120"/>
                    </Border>
                </pv:PivotViewerItemTemplate>
            </pv:PivotViewer.ItemTemplates>
        </pv:PivotViewer>
        <Image HorizontalAlignment="Left" Height="100" Margin="704,108,-404,0" VerticalAlignment="Top" Width="100" Source="images/bild.png" />
        <Image HorizontalAlignment="Left" Height="100" Margin="704,143,-404,0" VerticalAlignment="Top" Width="100" Source="images/bild4.png"/>
    </Grid>
</UserControl>
public MainPage()
        {
            InitializeComponent();
            List<Person> birthdayBook = new List<Person>();
            birthdayBook.Add(new Person("Brad", 25, new DateTime(1986, 5, 9), "images/bild.png"));
            birthdayBook.Add(new Person("Janet", 12, new DateTime(1998, 12, 3), "images/bild3.png"));
            birthdayBook.Add(new Person("Rocky", 43, new DateTime(1968, 7, 17), "images/bild4.png"));
            birthdayBook.Add(new Person("Magenta", 21, new DateTime(1990, 2, 21), "images/bild.png"));

            pivotviewer.DataContext = birthdayBook;
}