これは、ItemsControl.ItemTemplate プロパティ のMSDN ライブラリ記事から抜粋した XAML コード サンプルです。
<ListBox Width="400" Margin="10" ItemsSource="{Binding Source={StaticResource myTodoList}}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=TaskName}" />
<TextBlock Text="{Binding Path=Description}"/>
<TextBlock Text="{Binding Path=Priority}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel>
この例の要素の使用法の説明を探しています。
->
このパネルは ListBox のどこに存在しますか?
ItemTemplate での目的は何ですか?
System.Windows.Controls.Panel をその代わりに、特にグリッドで使用できますか? ListBox の各項目のテンプレートとして要素を
使用するにはどうすればよいですか?<Grid>
これが私が目指しているコンセプトです:
http://img151.imageshack.us/img151/7960/graphconcept.png
要素を使用してグラフを描画しました<Path>
が、問題はありません。
私は軸のラベルに取り組んでおり<Grid>
、ItemTemplate の要素を使用して実験していますが、このコンテキストでグリッドがどのように機能するのかわかりません。また、MSDN はサンプルのパネルについて何も述べていません。コード。
Y 軸ラベルの XAML は現在、次のようになっています。
<ListBox Background="Transparent" BorderThickness="0" ItemsSource="{Binding Path=GraphLabelYData}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding Path=GraphLabelSpacing}" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="{Binding ElementName=GraphLabelYData, Path=GraphLabelMarkerLength}" />
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Bottom" Text="{Binding Path=GraphLabelTag}" />
<Rectangle Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Stroke="Black" Fill="Black" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
これは正しく見えますか?実行時には何も表示されませんが、データ バインディングとコード ビハインドのデバッグを開始する前に、XAML が正しくモデル化されていることを確認したいと考えています。