Avalonia 自定义 ListBox ListBoxItem 的 axaml 写法
一、代码
<ListBox>
<ListBox.ItemContainerTheme>
<ControlTheme TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Margin" Value="5" />
<Style Selector="^:pointerover">
<Setter Property="Background" Value="Red" />
</Style>
<Style Selector="^:selected">
<Setter Property="Background" Value="Aqua" />
</Style>
</ControlTheme>
</ListBox.ItemContainerTheme>
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
<ListBoxItem Content="Nihao1" />
</ListBox>
二、效果
![]()