最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

WPF Trigger on template item for a button - Stack Overflow

programmeradmin5浏览0评论

I would like to change the Line color during IsMouseOver event:

    <Style x:Key="UiButtonNoTextEdit" BasedOn="{StaticResource UiButtonNoText}" TargetType="{x:Type Button}">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border BorderBrush="{StaticResource Br_Azzurro_01}" BorderThickness="1.8" CornerRadius="2" Style="{StaticResource UiButtonBorder}">
                        <StackPanel Orientation="Vertical">
                            <Viewbox UseLayoutRounding="False" Width="30" Height="30" VerticalAlignment="Top" Margin="0,5,0,0">
                                <Canvas ClipToBounds="True" Width="30" Height="30" >
                                    <Path Name="btnPath" Fill="{StaticResource Br_Azzurro_01}" Data="{StaticResource BtnDelete}" Stretch="Fill" Width="30" Height="30"/>
                                </Canvas>
                            </Viewbox>
                            <Line x:Name="line" X1="6" X2="44" StrokeStartLineCap="Round" StrokeEndLineCap="Round" HorizontalAlignment="Stretch" Margin="2,9,3,3" Stroke="{StaticResource Br_Blu_00}" StrokeThickness="4"/>
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Basically I can't reach the "line" element with my trigger

<Style x:Key="UiButtonBorder" TargetType="{x:Type Border}">
    <Style.Triggers>
        <Trigger Property="Button.IsMouseOver" Value="False">
            <Setter Property="Button.Foreground" Value="{StaticResource Br_Azzurro_02}" />
            <Setter Property="Border.Background" Value="{StaticResource UiButtonGradient}" />
        </Trigger>
        <Trigger Property="Button.IsMouseOver" Value="True">
            <Setter Property="Button.Foreground" Value="{StaticResource Br_Azzurro_02}" />
            <Setter Property="Border.Background" Value="{StaticResource UiButtonGradientOver}" />
        </Trigger>
    </Style.Triggers>
</Style>

I've been able to apply the trigger on Line element but the IsMouseOver on button is what I would.

发布评论

评论列表(0)

  1. 暂无评论