2011-11-05 77 views
0

當鼠標將鼠標懸停時,我試圖將OuterGlowBitmapEffect效果添加到TextBox。 我使用觸發器。這裏是一些代碼: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> 

但它不工作。我錯過了什麼?

+0

你不應該使用['BitmapEffect'(http://msdn.microsoft.com/en-us/library/system.windows.uielement.bitmapeffect.aspx) 。 –

+0

那麼我需要使用什麼? –

+0

它在第一行 –

回答

1

BitmapEffect文檔:

[ObsoleteAttribute( 「BitmapEffects被廢棄,不再功能考慮使用效果酌情代替。」)

可以使用模擬輝光Effect屬性,其實例爲DropShadowEffect

+0

是的,它的幫助 –

0

試試這個

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

我不認爲它將與價值「效果」 –

+0

工作是的,它的工作原理,我已經這樣做了,但謝謝:) –

+0

只看到HB的答案 –