Applying Generic Style on UIElement

Oct 14, 2009 at 12:03 PM

Hi Guys,

I want to apply a generic event setter style to a UIElement's GotFocus but it doesnt apply to the only textbox on my UI.

This way...


<Window x:Class="Window4"
Title="Window4" Height="300" Width="300">

    <Style TargetType="{x:Type UIElement}">
       <EventSetter Event="GotFocus" Handler="UIElementFocus"/>
         <Trigger Property="IsFocused" Value="True">
           <Setter Property="UIElement.Opacity" Value="70"/>

<StackPanel Orientation="Vertical">
<TextBox Text="Put Focus On Me Please!"/>

I am expecting the style to apply all the UI elements on the current window. (The trigger for opacity is just an extra check if whether the UIElement I have focused becomes opaque)


But it seems not to be happening. UIElementFocus event handler is not getting called. 

Am I missing something here?

Vinit Sankhe