admin管理员组

文章数量:1391934

Trying a pretty straight-forward thing in AXAML.

The the background color changes on hover, but not on pressed.

I've tried setting IsHitTestVisible of the enclosed label to true and Background of the label to Transparent and {x:Null} in an effort to prevent it from intercepting the click, but that didn't change anything.

I also tried changing the order of the styles so that pressed comes before hover.

<Grid Width="300" Height="100" HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid.Styles>
        <Style Selector="Grid">
            <Setter Property="Background" Value="DarkSlateGray"/>
        </Style>
        <Style Selector="Grid:pointerover">
            <Setter Property="Background" Value="Red"/>
        </Style>
        <Style Selector="Grid:pointerpressed">
            <Setter Property="Background" Value="MediumPurple"/>
        </Style>
    </Grid.Styles>

    <Label Content="TEST" Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Grid>

本文标签: cAvalonia UI AXAML styling issue for selector pointerpressedStack Overflow