Home > other >  Set Bitmap Effect on Hover in WPF Visual Studio
Set Bitmap Effect on Hover in WPF Visual Studio

Time:12-25

I have a border element on which I have bitmap effect of shadow:

    <Border x:Name="ListItemPressable"
        Background="{StaticResource CanvasBrush}"
        CornerRadius="5"
        MouseDown="ListItemPressed" Cursor="Hand"
        BitmapEffect="{StaticResource BottomShadowEffect}">
    </Border>

I want to show this bitmap effect only when border element is hovered on. How can I achieve this thing?

CodePudding user response:

Ok I just figured it out myself. For anyone looking for it, here's solution:

<Border.Style>
    <Style TargetType="{x:Type Border}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="BitmapEffect" Value="{StaticResource BottomShadowEffect}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Border.Style>
  • Related