0

Triggers とホバー効果のあるボタンがたくさんあります。TextBlockテーマをオーバーライドする際にいくつかの問題が見つかったので、 s やsなどの他の要素にマウス ホバー効果を追加できないかと考えていましStackPanelた。それは可能ですか?

4

2 に答える 2

1

それが可能であることがわかりました。念のため、回答のままにしておきます。

のホバー状態TextBlock:

<TextBlock Text="Textblock">   
        <TextBlock.Style>    
            <Style TargetType="TextBlock">      
                <Style.Triggers>         
                    <Trigger Property="IsMouseOver" Value="True">     
                        <Setter Property="TextBlock.Background" Value="Blue" />   
                    </Trigger>    
                </Style.Triggers>     
            </Style>   
        </TextBlock.Style>
    </TextBlock>
于 2013-01-14T21:50:23.747 に答える
1

はい、可能ですが、制限があります。ただし、背景の設定が唯一の単純なオプションです

  <TextBlock Text="Hello World!" Margin="0,23,0,111">
            <TextBlock.Style>
                <Style TargetType="TextBlock">
                    <Setter Property= "Background" Value="Transparent"/>
                    <Style.Triggers>
                       <Trigger Property ="IsMouseOver" Value="True">
                            <Setter Property= "Background" >
                                <Setter.Value>
                                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                        <GradientStopCollection>
                                            <GradientStop Color="Aqua" Offset="0" />
                                            <GradientStop Color="Transparent" Offset="1" />
                                        </GradientStopCollection>
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                       </Trigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
        </TextBlock>

結果

ここに画像の説明を入力 ここに画像の説明を入力

于 2013-01-14T21:54:55.940 に答える