6
6
<converters : TextFieldHintVisibilityConverter x : Key =" TextFieldHintVisibilityConverter" />
7
7
8
8
<Style x : Key =" MaterialDesignTextBox" TargetType =" {x:Type TextBox}" >
9
- <Setter Property =" Foreground" Value =" {Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}" />
10
- <Setter Property =" BorderBrush" Value =" {DynamicResource MaterialDesignTextBoxBorder}" />
9
+ <Setter Property =" Foreground" Value =" {Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}" />
10
+ <Setter Property =" BorderBrush" Value =" {DynamicResource MaterialDesignTextBoxBorder}" />
11
11
<Setter Property =" BorderThickness" Value =" 0 0 0 1" />
12
12
<Setter Property =" wpf:TextField.TextBoxViewMargin" Value =" 1 0 1 0" />
13
13
<Setter Property =" Background" Value =" Transparent" />
14
- <Setter Property =" CaretBrush" Value =" {Binding RelativeSource={RelativeSource Self}, Path=BorderBrush}" />
14
+ <Setter Property =" CaretBrush" Value =" {Binding RelativeSource={RelativeSource Self}, Path=BorderBrush}" />
15
15
<Setter Property =" KeyboardNavigation.TabNavigation" Value =" None" />
16
16
<Setter Property =" HorizontalContentAlignment" Value =" Left" />
17
17
<Setter Property =" FocusVisualStyle" Value =" {x:Null}" />
18
18
<Setter Property =" AllowDrop" Value =" true" />
19
19
<Setter Property =" ScrollViewer.PanningMode" Value =" VerticalFirst" />
20
- <Setter Property =" Stylus.IsFlicksEnabled" Value =" False" />
20
+ <Setter Property =" Stylus.IsFlicksEnabled" Value =" False" />
21
21
<Setter Property =" Validation.ErrorTemplate" >
22
22
<Setter .Value>
23
23
<ControlTemplate >
35
35
Padding =" 0 4 0 4" >
36
36
<Grid >
37
37
<ScrollViewer x : Name =" PART_ContentHost" Focusable =" false" HorizontalScrollBarVisibility =" Hidden" VerticalScrollBarVisibility =" Hidden"
38
- />
38
+ />
39
39
<TextBlock Text =" {Binding Path=(wpf:TextField.Hint), RelativeSource={RelativeSource TemplatedParent}}"
40
40
Visibility =" {TemplateBinding Text, Converter={StaticResource TextFieldHintVisibilityConverter}}"
41
41
x : Name =" Hint"
73
73
</Style .Triggers>
74
74
</Style >
75
75
76
+ <Style x : Key =" MaterialDesignFloatingHintTextBox" TargetType =" {x:Type TextBox}" BasedOn =" {StaticResource MaterialDesignTextBox}" >
77
+ <Setter Property =" wpf:TextField.Text" Value =" {Binding RelativeSource={RelativeSource Self}, Path=Text}" />
78
+ <Setter Property =" Template" >
79
+ <Setter .Value>
80
+ <ControlTemplate TargetType =" TextBox" >
81
+ <ControlTemplate .Resources>
82
+ <Storyboard x : Key =" MoveHintAsideStoryboard" >
83
+ <DoubleAnimation Storyboard.TargetProperty=" FontSize" Storyboard.TargetName=" Hint"
84
+ Duration =" 0:0:0.3" To =" 10" >
85
+ <DoubleAnimation .EasingFunction>
86
+ <SineEase EasingMode =" EaseOut" />
87
+ </DoubleAnimation .EasingFunction>
88
+ </DoubleAnimation >
89
+ <ThicknessAnimation Storyboard.TargetProperty=" (FrameworkElement.Margin)" Storyboard.TargetName=" Hint"
90
+ Duration =" 0:0:0.3" To =" 1,-16,1,0" >
91
+ <ThicknessAnimation .EasingFunction>
92
+ <SineEase EasingMode =" EaseOut" />
93
+ </ThicknessAnimation .EasingFunction>
94
+ </ThicknessAnimation >
95
+ </Storyboard >
96
+ <Storyboard x : Key =" MoveHintBackStoryboard" >
97
+ <DoubleAnimation Storyboard.TargetProperty=" FontSize" Storyboard.TargetName=" Hint"
98
+ Duration =" 0:0:0.3" >
99
+ <DoubleAnimation .EasingFunction>
100
+ <SineEase EasingMode =" EaseOut" />
101
+ </DoubleAnimation .EasingFunction>
102
+ </DoubleAnimation >
103
+ <ThicknessAnimation Storyboard.TargetProperty=" (FrameworkElement.Margin)" Storyboard.TargetName=" Hint"
104
+ Duration =" 0:0:0.3" >
105
+ <ThicknessAnimation .EasingFunction>
106
+ <SineEase EasingMode =" EaseOut" />
107
+ </ThicknessAnimation .EasingFunction>
108
+ </ThicknessAnimation >
109
+ </Storyboard >
110
+ </ControlTemplate .Resources>
111
+ <Border x : Name =" border" BorderBrush =" {TemplateBinding BorderBrush}" BorderThickness =" {TemplateBinding BorderThickness}" Background =" {TemplateBinding Background}" SnapsToDevicePixels =" True"
112
+ Padding =" 0 4 0 4" >
113
+ <Grid Margin =" 0 12 0 0" >
114
+ <ScrollViewer x : Name =" PART_ContentHost" Focusable =" false" HorizontalScrollBarVisibility =" Hidden" VerticalScrollBarVisibility =" Hidden"
115
+ />
116
+ <TextBlock Text =" {Binding Path=(wpf:TextField.Hint), RelativeSource={RelativeSource TemplatedParent}}"
117
+ FontSize =" {TemplateBinding FontSize}"
118
+ HorizontalAlignment =" Left"
119
+ x : Name =" Hint"
120
+ Margin =" 1 0 1 0"
121
+ Opacity =" {Binding Path=(wpf:TextField.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}" />
122
+ </Grid >
123
+ </Border >
124
+ <ControlTemplate .Triggers>
125
+ <Trigger Property =" wpf:TextField.IsNullOrEmpty" Value =" False" >
126
+ <Trigger .EnterActions>
127
+ <BeginStoryboard x : Name =" MoveHintAsideStoryboard_BeginStoryboard" Storyboard =" {StaticResource MoveHintAsideStoryboard}" />
128
+ </Trigger .EnterActions>
129
+ <Trigger .ExitActions>
130
+ <BeginStoryboard x : Name =" MoveHintBackStoryboard_BeginStoryboard" Storyboard =" {StaticResource MoveHintBackStoryboard}" />
131
+ </Trigger .ExitActions>
132
+ </Trigger >
133
+ <Trigger Property =" IsEnabled" Value =" false" >
134
+ <Setter Property =" Opacity" TargetName =" border" Value =" 0.56" />
135
+ </Trigger >
136
+ <Trigger Property =" IsMouseOver" Value =" true" >
137
+ <Setter Property =" BorderBrush" Value =" {DynamicResource PrimaryHueMidBrush}" />
138
+ </Trigger >
139
+ <Trigger Property =" IsKeyboardFocused" Value =" true" >
140
+ <Setter TargetName =" border" Property =" Padding" Value =" 0 4 0 3" />
141
+ <Setter Property =" BorderThickness" Value =" 0 0 0 2" />
142
+ <Setter Property =" BorderBrush" Value =" {DynamicResource PrimaryHueMidBrush}" />
143
+ </Trigger >
144
+ <Trigger Property =" Validation.HasError" Value =" true" >
145
+ <Setter Property =" BorderBrush" Value =" #f44336" />
146
+ </Trigger >
147
+ </ControlTemplate .Triggers>
148
+ </ControlTemplate >
149
+ </Setter .Value>
150
+ </Setter >
151
+ </Style >
152
+
76
153
</ResourceDictionary >
0 commit comments