Silverlight 5 Pivotviewer で Visual Studio 2013 を使用しています。数年前、私はすでに前任者でいくつかの Pivotviewer を行っていましたが、その方法でうまく機能しました (Excel プラグイン ツール)。今、コードとバージョン 5 だけでピボットビューアーを作成しようとしています。
一種の誕生日の本を示しているインターネットから例を挙げました。この例の PivotViewerItemTemplate は、テキスト ボックスのある単純な境界線です。すべて正常に機能していますが、ソースタグが文字列にバインドされている PivotViewerItemTemplate に画像ファイルを含めたいと思いました。どういうわけか、ツールボックスを介して別の画像をウィンドウのどこかに手動で配置するまで、画像を取得できませんでした。これで、pivotviewer はバインディングを通過したすべてのオブジェクトの画像を表示し始めました。デバッグしたところ、バインディングがすべての人に対して正しく機能していることがわかりました。
メインページ.xaml
<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>
下部にあるように、2 つの画像を配置した後、pivotviewer が画像 bild4 と bild を受け入れ始めました。そのため、「ブラッド」と「ロッキー」は現在、それらの画像とともに表示されています。下から2つの画像行を削除した後、pivotviewerは境界線とその背景色以外は何も表示しませんでした.
MainPage.xaml.cs
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;
}
ItemTemplate タグの xaml コードに問題があると思いますが、どこでしょうか? bild (120x120)、bild3 (485x485)、bild4 (120x120) のプロパティ。画像はその画像フォルダーのプロジェクトに含まれており、ビルド アクションは Resource です。