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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MaterialDesignTheme.ValidationErrorTemplate.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:TextFieldHintVisibilityConverter x:Key="TextFieldHintVisibilityConverter" />
<Style x:Key="MaterialDesignTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
<Setter Property="BorderBrush" Value="{DynamicResource MaterialDesignTextBoxBorder}" />
<Setter Property="BorderThickness" Value="0 0 0 1"/>
<Setter Property="wpf:TextFieldAssist.TextBoxViewMargin" Value="0 0 0 0" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="CaretBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Bottom"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource MaterialDesignValidationErrorTemplate}"/>
<Setter Property="wpf:TextFieldAssist.IncludeSpellingSuggestions" Value="{Binding RelativeSource={RelativeSource Self}, Path=(SpellCheck.IsEnabled)}" />
<!-- cludge the default context menu -->
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Header="_Cut" Command="Cut">
<MenuItem.Icon>
<wpf:PackIcon Kind="ContentCut"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="_Copy" Command="Copy">
<MenuItem.Icon>
<wpf:PackIcon Kind="ContentCopy" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="_Paste" Command="Paste">
<MenuItem.Icon>
<wpf:PackIcon Kind="ContentPaste"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="textFieldBoxBorder"
SnapsToDevicePixels="True">
<Grid>
<Border x:Name="border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True"
Padding="0 4 0 4">
<Grid x:Name="textFieldGrid"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ScrollViewer x:Name="PART_ContentHost" Focusable="false"
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
/>
<wpf:SmartHint x:Name="Hint"
Hint="{Binding Path=(wpf:HintAssist.Hint), RelativeSource={RelativeSource TemplatedParent}}"
HintProxy="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:HintProxyFabricConverter.Instance}}"
FontSize="{TemplateBinding FontSize}"
Padding="{TemplateBinding Padding}"
HintOpacity="{Binding Path=(wpf:HintAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}"
UseFloating="{Binding Path=(wpf:HintAssist.IsFloating), RelativeSource={RelativeSource TemplatedParent}}"
FloatingScale="{Binding Path=(wpf:HintAssist.FloatingScale), RelativeSource={RelativeSource TemplatedParent}}"
FloatingOffset="{Binding Path=(wpf:HintAssist.FloatingOffset), RelativeSource={RelativeSource TemplatedParent}}"
/>
</Grid>
</Border>
<Line x:Name="DashedLine" VerticalAlignment="Bottom" Visibility="Hidden"
StrokeThickness="1.25" StrokeDashArray="1,2.5" StrokeDashCap="Round"
X1="0" X2="{Binding ActualWidth, ElementName=border}" Y1="0" Y2="0"
Stroke="{TemplateBinding BorderBrush}" Opacity="0.56" />
<wpf:Underline x:Name="Underline" Visibility="{Binding Path=(wpf:TextFieldAssist.DecorationVisibility), RelativeSource={RelativeSource TemplatedParent}}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="wpf:HintAssist.IsFloating" Value="True" />
<Condition Property="IsKeyboardFocused" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Hint" Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}" />
<Setter TargetName="Hint" Property="HintOpacity" Value="1" />
</MultiTrigger>
<Trigger Property="wpf:HintAssist.IsFloating" Value="True">
<Setter TargetName="border" Property="Margin" Value="0 12 0 0" />
</Trigger>
<Trigger Property="wpf:TextFieldAssist.HasTextFieldBox" Value="True">
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter TargetName="textFieldBoxBorder" Property="Background" Value="{DynamicResource MaterialDesignTextFieldBoxBackground}" />
<Setter TargetName="textFieldBoxBorder" Property="CornerRadius" Value="4" />
<Setter TargetName="textFieldBoxBorder" Property="Padding" Value="0,8,0,0" />
<Setter TargetName="textFieldGrid" Property="Margin" Value="16,0,16,0" />
<Setter TargetName="border" Property="BorderThickness" Value="0" />
<Setter TargetName="Underline" Property="CornerRadius" Value="0,0,4,4" />
<Setter TargetName="Hint" Property="Margin" Value="0,0,0,16" />
<Setter TargetName="PART_ContentHost" Property="Margin" Value="0,8,0,8" />
</Trigger>
<Trigger Property="wpf:TextFieldAssist.HasTextAreaBox" Value="True">
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter TargetName="textFieldBoxBorder" Property="Background" Value="Transparent" />
<Setter TargetName="textFieldBoxBorder" Property="CornerRadius" Value="4" />
<Setter TargetName="textFieldBoxBorder" Property="BorderThickness" Value="1" />
<Setter TargetName="textFieldBoxBorder" Property="BorderBrush" Value="{DynamicResource MaterialDesignTextAreaBorder}" />
<Setter TargetName="textFieldBoxBorder" Property="Padding" Value="0,8,0,0" />
<Setter TargetName="textFieldBoxBorder" Property="Margin" Value="-1" />
<Setter TargetName="textFieldGrid" Property="Margin" Value="16,0,16,0" />
<Setter TargetName="border" Property="BorderThickness" Value="0" />
<Setter TargetName="Underline" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Hint" Property="Margin" Value="0,0,0,16" />
<Setter TargetName="PART_ContentHost" Property="Margin" Value="0,8,0,8" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="false" />
<Condition Property="wpf:TextFieldAssist.HasTextAreaBox" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="textFieldBoxBorder" Property="Background" Value="{DynamicResource MaterialDesignTextFieldBoxDisabledBackground}" />
<Setter TargetName="textFieldBoxBorder" Property="BorderBrush" Value="{DynamicResource MaterialDesignTextAreaInactiveBorder}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="false" />
<Condition Property="wpf:TextFieldAssist.HasTextAreaBox" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Opacity" TargetName="border" Value="0.42"/>
<Setter TargetName="border" Property="BorderBrush" Value="Transparent" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="false" />
<Condition Property="wpf:TextFieldAssist.HasTextAreaBox" Value="False" />
<Condition Property="wpf:TextFieldAssist.HasTextFieldBox" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="DashedLine" Property="Visibility" Value="Visible" />
</MultiTrigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter TargetName="Underline" Property="IsActive" Value="True"/>
</Trigger>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="BorderBrush" Value="{DynamicResource ValidationErrorBrush}"/>
<Setter TargetName="Underline" Property="Background" Value="{DynamicResource ValidationErrorBrush}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="wpf:TextFieldAssist.HasTextAreaBox" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="textFieldBoxBorder" Property="Margin" Value="-2" />
<Setter TargetName="textFieldBoxBorder" Property="BorderThickness" Value="2" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsKeyboardFocused" Value="True" />
<Condition Property="wpf:TextFieldAssist.HasTextAreaBox" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="textFieldBoxBorder" Property="Margin" Value="-2" />
<Setter TargetName="textFieldBoxBorder" Property="BorderThickness" Value="2" />
<Setter TargetName="textFieldBoxBorder" Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Validation.HasError" Value="True" />
<Condition Property="wpf:TextFieldAssist.HasTextAreaBox" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="textFieldBoxBorder" Property="Margin" Value="-2" />
<Setter TargetName="textFieldBoxBorder" Property="BorderThickness" Value="2" />
<Setter TargetName="textFieldBoxBorder" Property="BorderBrush" Value="{DynamicResource ValidationErrorBrush}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
</MultiTrigger>
</Style.Triggers>
</Style>
<Style x:Key="MaterialDesignFloatingHintTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}">
<Setter Property="wpf:HintAssist.IsFloating" Value="True"/>
</Style>
<Style x:Key="MaterialDesignTextFieldBoxTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}">
<Setter Property="wpf:TextFieldAssist.HasTextFieldBox" Value="True" />
</Style>
<Style x:Key="MaterialDesignTextAreaTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}">
<Setter Property="wpf:TextFieldAssist.HasTextAreaBox" Value="True" />
</Style>
</ResourceDictionary>
|