我正在嘗試更改 MaterialDesign ListBoxItem 樣式的背景顏色,但無法使其正常作業。
我知道如何覆寫這樣的樣式:
<Style x:Key="MaterialDesignListBoxItem"
TargetType="ListBoxItem"
BasedOn="{StaticResource MaterialDesignListBoxItem}">
</Style>
但我不會得到 MaterialDesign 影片,因為它只是一個常規按鈕。
有什么方法可以改變背景顏色并保持 MaterialDesign 的外觀和感覺?
uj5u.com熱心網友回復:
將 的ItemContainerStyle屬性設定為基于ListBox的自定義,例如:StyleMaterialDesignListBoxItem
<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MaterialDesignListBoxItem}">
<Setter Property="Background" Value="Green" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/489033.html
