【发布时间】:2016-07-01 14:39:05
【问题描述】:
<Border Grid.Row="1" Padding="15" Margin="15" BorderBrush="LightBlue" Background="AliceBlue" BorderThickness="1">
<ListBox ItemsSource="{Binding Configs}">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Focusable" Value="False" />
<Setter Property="BorderThickness" Value="0" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<view:Config />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
这是我用 XAML 编写的代码。但是,它似乎没有任何影响。
在 SO 上有很多类似问题的帖子,但他们的所有回复都是“使用 ListBox.ItemContainerStyle”,我已经这样做了:S 例如 There is no ListBox.SelectionMode="None", is there another way to disable selection in a listbox? 和 WPF, XAML: How to style a ListBoxItem using binding on property of ListBox ItemsSource object?
我期望的是没有背景,没有边框,并且项目不可聚焦。
我做错了什么?
【问题讨论】: