【问题标题】:Styles and Triggers in TextBoxTextBox 中的样式和触发器
【发布时间】:2011-12-22 17:16:56
【问题描述】:

当鼠标悬停时,我正在尝试将 OuterGlowBitmapEffect 效果添加到 TextBox。 我使用触发器。这是一些代码:

<TextBox Height="23" HorizontalAlignment="Left" Style="{DynamicResource TextBoxStyle}" Margin="12,283,0,0" Name="textBox1" VerticalAlignment="Top" Width="147" Text="" />

<Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
    <Setter Property="FontSize" Value="14" />
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="BitmapEffect">
                <Setter.Value>
                    <OuterGlowBitmapEffect GlowColor="Red" GlowSize="10"/>
                </Setter.Value>
            </Setter>
        </Trigger>
    </Style.Triggers>
</Style>

但它不起作用。我错过了什么?

【问题讨论】:

标签: c# .net wpf triggers styles


【解决方案1】:

来自BitmapEffect的文档:

[ObsoleteAttribute("BitmapEffects 已弃用且不再起作用。请考虑在适当的情况下使用 Effects。")]

您可以使用Effect 属性和DropShadowEffect 的实例来模拟发光。

【讨论】:

    【解决方案2】:

    试试这个

    <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Effect">
                    <Setter.Value>
                        <DropShadowEffect BlurRadius="10" Color="Red" ShadowDepth="0"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
    

    【讨论】:

      猜你喜欢
      • 2011-09-20
      • 1970-01-01
      • 2015-10-26
      • 2019-07-22
      • 2010-10-15
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      相关资源
      最近更新 更多