Avalonia 自定义 ListBox ListBoxItem 的 axaml 写法

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>

二、效果

posted @ 2025-03-12 15:11  fanbal  阅读(424)  评论(0)    收藏  举报