私はこれに対する解決策を見つけることができません.. DataTemplate に ComboBox がある ListBox があります。DataBinding が用意されています。これは一種のコレクション シナリオのコレクションです。すべての ComboBox に「Select One Item」を付加したいと考えています。それ、どうやったら出来るの?
編集:上記の質問にコード/xamlが必要な理由が本当にわかりません。しかし、とにかく以下:
<Resources>
<ResourceDictionary>
<DataTemplate x:Key="CategoriesDataTemplate">
<StackPanel Orientation="vertical">
<TextBlock Text="{Binding Path=CategoryName}"></TextBlock>
<ComboBox ItemsSource="{Binding Path=Products}" Background="Transparent" SelectedValuePath="ProductId" DisplayMemberPath="ProductName">
</ComboBox>
</StackPanel>
</DataTemplate>
</ResourceDictionary>
</Resources>
.....
<Grid..>
<ListBox ItemsSource="{Binding Categories}" ItemTemplate="{DynamicResource CategoriesDataTemplate}">
</Grid>
カテゴリーごとに、カテゴリー名とその商品のコンボボックスを下に表示します。ユーザーは、カテゴリごとに 1 つの製品を選択できます。そのようなコンボボックスごとに、最初の項目を「製品の選択」などにしたいと思います。注:各カテゴリの各製品コレクションにアイテムを事前に保留せずにそれを行う方法があるかどうかを確認しています(可能であればソースコレクションを台無しにしたくありません)。ある種のイベント ハンドラー アプローチですか?