我正在尝试为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>