【问题标题】:WPF, My IsMouseOver of my Grid doesnt change the Backgroundcolor [duplicate]WPF,我的网格的 IsMouseOver 不会改变背景颜色 [重复]
【发布时间】:2021-04-08 13:06:31
【问题描述】:
<Grid x:Name="set_bg" DockPanel.Dock="Top" Height="90" Background="Transparent" MouseDown="set_bg_MouseDown">
    <Grid.Style>
        <Style TargetType="{x:Type Grid}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="DarkGoldenrod"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Grid.Style>
    <Image Height="66" Opacity="0.7" Source="/Images/settings.png" RenderOptions.BitmapScalingMode="HighQuality"/>
</Grid>

我真的不知道为什么这不起作用,即使一切都应该没问题

【问题讨论】:

标签: c# wpf


【解决方案1】:

只需删除Background="Transparent"。 触发器实际上是在改变背景颜色,但是设置为透明时是看不到的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 2021-10-29
    • 2022-06-11
    • 2014-06-21
    • 2014-04-21
    • 2021-01-23
    • 2011-06-15
    相关资源
    最近更新 更多