Skip to content

Commit cb67de8

Browse files
authored
Added attachable property Background to HintAssist. (#1807)
Default value is Transparent for TextBoxBase, default for MaterialDesignOutlinedTextFieldTextBox is MaterialDesignPaper.
1 parent 8856183 commit cb67de8

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

MaterialDesignThemes.Wpf/HintAssist.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,28 @@ public static void SetForeground(DependencyObject element, Brush value)
154154
element.SetValue(ForegroundProperty, value);
155155
}
156156

157+
/// <summary>
158+
/// The color for the background of a focused control.
159+
/// </summary>
160+
public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached(
161+
"Background", typeof(Brush), typeof(HintAssist), new PropertyMetadata(null));
162+
163+
/// <summary>
164+
/// Gets the color for the background of a focused control.
165+
/// </summary>
166+
public static Brush GetBackground(DependencyObject element)
167+
{
168+
return (Brush)element.GetValue(BackgroundProperty);
169+
}
170+
171+
/// <summary>
172+
/// Sets the color for the background of a focused control.
173+
/// </summary>
174+
public static void SetBackground(DependencyObject element, Brush value)
175+
{
176+
element.SetValue(BackgroundProperty, value);
177+
}
178+
157179
#endregion
158180

159181
#region HelperText

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<Setter Property="wpf:TextFieldAssist.IncludeSpellingSuggestions" Value="{Binding RelativeSource={RelativeSource Self}, Path=(SpellCheck.IsEnabled)}" />
3535
<Setter Property="wpf:TextFieldAssist.UnderlineBrush" Value="{DynamicResource PrimaryHueMidBrush}" />
3636
<Setter Property="wpf:HintAssist.Foreground" Value="{DynamicResource PrimaryHueMidBrush}" />
37+
<Setter Property="wpf:HintAssist.Background" Value="Transparent" />
3738
<Setter Property="ContextMenu" Value="{StaticResource MaterialDesignDefaultContextMenu}"/>
3839
<Setter Property="Template">
3940
<Setter.Value>
@@ -165,6 +166,7 @@
165166
</MultiTrigger>
166167
<Trigger Property="wpf:HintAssist.IsFloating" Value="True">
167168
<Setter TargetName="border" Property="Margin" Value="0 18 0 0" />
169+
<Setter TargetName="HintBackgroundBorder" Property="Background" Value="{Binding Path=(wpf:HintAssist.Background), RelativeSource={RelativeSource TemplatedParent}}" />
168170
</Trigger>
169171
<Trigger Property="wpf:TextFieldAssist.HasFilledTextField" Value="True">
170172
<Setter TargetName="textFieldBoxBorder" Property="Background" Value="{DynamicResource MaterialDesignTextFieldBoxHoverBackground}"/>
@@ -210,7 +212,6 @@
210212
<Setter TargetName="Hint" Property="FloatingOffset" Value="{Binding FontSize, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource FontSizeToHintOffsetConverter}}" />
211213
<Setter TargetName="HintWrapper" Property="Opacity" Value="{Binding Path=(wpf:HintAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}" />
212214
<Setter TargetName="HintBackgroundBorder" Property="Padding" Value="4, 0" />
213-
<Setter TargetName="HintBackgroundBorder" Property="Background" Value="{DynamicResource MaterialDesignPaper}" />
214215
</Trigger>
215216
<MultiTrigger>
216217
<MultiTrigger.Conditions>
@@ -353,6 +354,7 @@
353354
<Style x:Key="MaterialDesignOutlinedTextFieldTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}">
354355
<Setter Property="wpf:TextFieldAssist.HasOutlinedTextField" Value="True" />
355356
<Setter Property="wpf:TextFieldAssist.TextFieldCornerRadius" Value="4" />
357+
<Setter Property="wpf:HintAssist.Background" Value="{DynamicResource MaterialDesignPaper}" />
356358
</Style>
357359

358360
</ResourceDictionary>

0 commit comments

Comments
 (0)