Bonjour,
Voici mon problème :
J'ai défini un style pour mes textbox avec un Trigger sur IsKeyboardFocused qui lance une animation sur la bordure.
Le soucis est que lorsque je dispose plusieurs textbox sur une fenetre et que je dirige le focus sur l'un d'eux, tous se mettent à s'animer.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!-- Couleur du fond des textbox --> <SolidColorBrush x:Key="TextBoxBackground" Color="White"/> <!-- Couleur du border des textbox --> <SolidColorBrush x:Key="TextBoxBorder" Color="Black"/> <!-- Couleur du foreground des textbox --> <SolidColorBrush x:Key="TextBoxForeground" Color="Black"/> <!-- Couleur du fond disabled des textbox --> <SolidColorBrush x:Key="TextBoxDisabledBackground" Color="#FF8A8A8A"/> <Style x:Key="MyTextBoxStyle" TargetType="{x:Type TextBox}"> <Setter Property="FontFamily" Value="/MyWpfLibrary;component/fonts/#Palatino Linotype"/> <Setter Property="FontSize" Value="12"/> <Setter Property="Foreground" Value="{StaticResource TextBoxForeground}"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="1"/> <Setter Property="AllowDrop" Value="False"/> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="TextWrapping" Value="NoWrap"/> <Setter Property="Height" Value="25"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <ControlTemplate.Resources> <Storyboard x:Key="Storyboard1"> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="border"> <EasingColorKeyFrame KeyTime="0" Value="White"/> <EasingColorKeyFrame KeyTime="0:0:0.5" Value="Black"/> <EasingColorKeyFrame KeyTime="0:0:1" Value="White"/> <EasingColorKeyFrame KeyTime="0:0:1.5" Value="Black"/> <EasingColorKeyFrame KeyTime="0:0:2" Value="White"/> <EasingColorKeyFrame KeyTime="0:0:2.5" Value="Black"/> </ColorAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources> <Border x:Name="border" Background="{StaticResource TextBoxBackground}" BorderBrush="{StaticResource TextBoxBorder}" BorderThickness="1" CornerRadius="5"> <ScrollViewer x:Name="PART_ContentHost"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsKeyboardFocused" Value="True"> <Trigger.EnterActions> <BeginStoryboard x:Name="Storyboard1_BeginStoryboard" Storyboard="{StaticResource Storyboard1}"/> </Trigger.EnterActions> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Background" Value="{StaticResource TextBoxDisabledBackground}" TargetName="border" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
Une idée?
Merci
Partager