如何在XAML中改变一个MaterialDesign ListBoxItem的背景?(WPF) &g



我试图改变MaterialDesign ListBoxItem样式的背景颜色,但是我不能让它工作。

我知道像这样重写样式:

<Style x:Key="MaterialDesignListBoxItem"
TargetType="ListBoxItem"
BasedOn="{StaticResource MaterialDesignListBoxItem}">

</Style>

但是我不会得到MaterialDesign动画,因为它只是一个普通的按钮。

有没有办法改变背景颜色,保持MaterialDesign的外观和感觉?

设置ListBoxItemContainerStyle属性为基于MaterialDesignListBoxItem的自定义Style,例如:

<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MaterialDesignListBoxItem}">
<Setter Property="Background" Value="Green" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>

最新更新