データバインドされたListBoxを取得して、ListBoxItemのテンプレート化されたスタイル(それぞれのスタイルと同じ名前のResourceDictionary内から)を受け入れるにはどうすればよいですか?
Blend 4で、SimpleStyles ResourceDictionaryファイル内で、「SimpleListBoxItem」のプロパティが次のように設定されていることがわかります。
d:IsControlPart="True"
しかし、これは、xamlのハードコードされたListBoxItemsにSimpleListBoxItemスタイルを明示的に使用する場合にのみ使用できますか?
私にとって理にかなっているのは、リストボックス内のControlTemplateにスタイルを適用することです。リストボックス内のコントロールテンプレートは次のようになります。
ControlTemplate TargetType="{x:Type ListBox}">
<Grid>
<Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
/>
<ScrollViewer Margin="1" Style="{DynamicResource SimpleScrollViewer}" Focusable="false" Background="{TemplateBinding Background}">
<!-- The StackPanel is used to display the children by setting IsItemsHost to be True -->
<StackPanel Margin="2" IsItemsHost="true"/>
</ScrollViewer>
</Grid>
そのスタックパネル内にもう1つのネストされた「ItemsHost」スタイルテンプレートを配置する方法はありますか?多分DataTemplate?
よろしくお願いします。さらに詳しい説明が必要な場合はお知らせください。