0

This is the continuation to this question.

I have applied this style to TextBox in xaml and a part from the problem above everything works fine.

<Style x:Key="stlFocusGlowingTextBox" TargetType="{x:Type TextBox}">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Foreground" Value="White" />
    <Setter Property="Effect">
        <Setter.Value>
            <DropShadowEffect ShadowDepth="0" Color="Yellow" Opacity="0" BlurRadius="20"/>
        </Setter.Value>
    </Setter>
    <Style.Triggers>
        <Trigger Property="IsFocused"  Value="True">
            <Trigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation To="1.0" Storybord.TargetProperty="(Effect).Opacity" Duration="00:00:00"/>
                    </Storyboard>
                </BeginStoryboard>
            </Trigger.EnterActions>
            <Trigger.ExitActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation To="0.0" Storyboard.TargetProperty="(Effect).Opacity" Duration="00:00:01"/>
                    </Storyboard>
                </BeginStoryboard>
            </Trigger.ExitActions>
        </Trigger>
        </Style.Triggers>
    </Style>

But now I need to apply the same effect NOT automatically on focus but programmatically. I have tried to delete the trigger but it didn't work.

Thank you in advance for your help Patrick

Community
  • 1
  • 1
Patrick
  • 2,743
  • 1
  • 18
  • 57
  • Have you thought about using a DataTrigger? – Michael Faisst Oct 20 '16 at 12:07
  • No I don't know data Trigger but is it necessary? Let's say I have 2 textboxes tbx1 and tbx2. I want to apply the style to tbx1 and see the glow, not apply it to tbx2 and don't see the glow. I tried to apply style (having deleted the trigger section) from xaml but it didn't work – Patrick Oct 20 '16 at 12:14
  • With a data trigger you could bind your trigger to any variable (e.g. a variable in your viewModel for controlling if the style should apply or not). For example something like this: ``. If that is something you would need, I could give you a more detailed example. – Michael Faisst Oct 20 '16 at 12:21
  • Or what exactly do you mean, when you say you want the glow on tbx1, but not on tbx2? Do you mean you never whant the style on tbx2, or just no style at the start, but can turn it on again via code? – Michael Faisst Oct 20 '16 at 12:25
  • I am trying to make it simple. I want the style to be applied from xml only to tbx1. That's easy I put it in the definition of the textbox. By doing that I want the textbox to always shine. I did it as a first step after having eliminated the trigger section. But that didn't work. – Patrick Oct 20 '16 at 14:12

0 Answers0