おそらく、ItemsControl が必要です。これにより、指定された DataTemplate を使用して一連のアイテムを提示できます。これは、ItemsControl のインラインで行うことができます。
<ItemsControl ItemsSource="{Binding MyCollectionOfItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding NameOfTheCheckedPropertyOnEachItem}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
または、リソースからデータ テンプレートを明示的に参照する...もっと似たようなもの:
<!-- In some parent resource section -->
<DataTemplate x:Key="MyDataTemplateName">
<CheckBox IsChecked="{Binding NameOfTheCheckedPropertyOnEachItem}"/>
</DataTemplate>
<!-- ... -->
<ItemsControl ItemsSource="{Binding MyCollectionOfItems}" ItemTemplate="{StaticResource MyDataTemplateName}">
</ItemsControl>
または、バインドされたクラスのルック アンド フィールを定義する DataTemplate を定義できます。(Linq-to-SQL が匿名型に射影している場合、これはオプションではないことに注意してください)。
<!-- In some parent resource section -->
<DataTemplate DataType="{x:Type MyBoundClass}">
<CheckBox IsChecked="{Binding NameOfTheCheckedPropertyOnEachItem}"/>
</DataTemplate>
<!-- ... -->
<ItemsControl ItemsSource="{Binding MyCollectionOfItems}">
</ItemsControl>
WPF は、コレクション内の各項目の DataType に一致する DataTemplate を探します。これは、異なるプレゼンテーションを必要とする異種コレクションをバインドするのに非常に役立つことに注意してください。
Stackpanel の DataContext をバインドすることはできますが、データの要素ごとにテンプレートを繰り返すことに関する固有のロジックはありません。子コントロールと含まれる{Binding ...}ステートメントのコンテキストを提供するだけです。繰り返しデータを処理するすべてのコントロールは、ItemsControl から派生し、ItemsSource プロパティを通じてデータを取得します。