WPF在其边界触发器中更改路径效果

本文关键字:路径 边界 触发器 WPF | 更新日期: 2023-09-27 18:19:40

我尝试了很多谷歌搜索,但都没有成功。我尝试了带绑定的DataTrigger,但没能成功。

这就是我想要的:

<Border x:Name="PART_WindowCaptionMinimizeButton"
        Width="15"
        Height="15"
        Background="#E1E1E1"
        Margin="0 0 0 4">
    <Path x:Name="minimizePath"
          Stroke="#3090C7"
          Data="m 3,11.5 8,0 0,0.5 -8,0 z" />
        <Border.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <!-- I WANT PATH (minimizepath) TO GET GLOW EFFECT -->
            </Trigger>
        </Border.Triggers>
</Border>

这是辉光效应代码:

<Setter Property="Effect">
    <Setter.Value>
        <DropShadowEffect ShadowDepth="0"
                          Color="#3090C7"
                          Opacity="0"
                          BlurRadius="7"/>
    </Setter.Value>
</Setter>

WPF在其边界触发器中更改路径效果

Border.Triggers只启用EventTrigger,然后不启用IsMouseOver,而是启用MouseEnter。给,试试这个

<Border x:Name="PART_WindowCaptionMinimizeButton"
                                Width="45"
                                Height="45"
                                Background="#E1E1E1"
                                Margin="0 0 0 4">
    <Path x:Name="minimizePath"
                                  Stroke="#3090C7"
                                  Data="m 3,11.5 8,0 0,0.5 -8,0 z" >
        <Path.Style>
            <Style TargetType="Path">
                <Setter Property="Effect" Value="{x:Null}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ElementName=PART_WindowCaptionMinimizeButton, Path=IsMouseOver}" Value="True">
                        <Setter Property="Effect">
                            <Setter.Value>
                                <DropShadowEffect ShadowDepth="0"
              Color="CadetBlue"
              Opacity="1"
              BlurRadius="7"/>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Path.Style>
    </Path>
</Border>