Я пытаюсь использовать режим Single Selection для моего ItemsControl. Поэтому я изменил мой ItemsControl на ListBox, однако получаю исключение: «Стиль, предназначенный для типа« ContentPresenter », нельзя применить к типу« ListBoxItem »» Что здесь? я не могу использовать ContentPresenter для ListBoxes?
<ListBox SelectionMode="Single" ItemsSource="{Binding}" MinHeight="200" MinWidth="200">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid></UniformGrid>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Grid.Row" Value="{Binding X}" />
<Setter Property="Grid.Column" Value="{Binding Y}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate DataType="ObservableCollection">
<Border BorderBrush="Black" BorderThickness="0.5" Background="Beige">
<clr:Cell Content="{Binding Character}"></clr:Cell>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>