Skip to content

Commit 6feb364

Browse files
committed
Merge branch 'master' into IconPack
2 parents ae51cbb + ceeb1b7 commit 6feb364

11 files changed

+227
-86
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@
108108
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0 16 0 0">
109109
<Button Style="{StaticResource MaterialDesignRaisedLightButton}" Margin="0 0 8 0" Width="100"
110110
ToolTip="Resource name: MaterialDesignRaisedLightButton">
111-
LIGHT
111+
_LIGHT
112112
</Button>
113113
<Button Style="{StaticResource MaterialDesignRaisedButton}" Margin="0 0 8 0" Width="100"
114114
ToolTip="Resource name: MaterialDesignRaisedButton">
115-
MID
115+
_MID
116116
</Button>
117117
<Button Style="{StaticResource MaterialDesignRaisedDarkButton}" Margin="0 0 8 0" Width="100"
118118
ToolTip="Resource name: MaterialDesignRaisedLightDarkButton">
119-
DARK
119+
_DARK
120120
</Button>
121121
<Button Style="{StaticResource MaterialDesignRaisedAccentButton}" Margin="0 0 8 0" Width="100"
122122
ToolTip="Resource name: MaterialDesignRaisedAccentButton">

MainDemo.Wpf/TextFields.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBox.xaml" />
2121
</ResourceDictionary.MergedDictionaries>
2222
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}">
23-
<Setter Property="HorizontalAlignment" Value="Stretch" />
23+
<Setter Property="Margin" Value="0 8 0 8" />
24+
</Style>
25+
<Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource MaterialDesignPasswordBox}">
2426
<Setter Property="Margin" Value="0 8 0 8" />
2527
</Style>
2628
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MaterialDesignComboBox}">

MaterialDesignThemes.Wpf/PasswordFieldAssist.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ private static void ManagedPropertyChangedCallback(DependencyObject dependencyOb
1717
if (passwordBox != null)
1818
{
1919
passwordBox.PasswordChanged -= PasswordBoxOnPasswordChanged;
20+
passwordBox.Loaded -= PasswordBoxOnPasswordChanged;
2021
}
2122

2223
passwordBox = dependencyPropertyChangedEventArgs.NewValue as PasswordBox;
2324
if (passwordBox != null)
2425
{
2526
passwordBox.PasswordChanged += PasswordBoxOnPasswordChanged;
26-
ConfigureHint(passwordBox);
27+
passwordBox.Loaded += PasswordBoxOnPasswordChanged;
2728
}
2829
}
2930

@@ -56,43 +57,61 @@ private static void ConfigureHint(PasswordBox passwordBox)
5657
passwordBox.SetValue(HintVisibilityProperty, passwordBox.SecurePassword.Length == 0 ? Visibility.Visible : Visibility.Hidden);
5758
}
5859

60+
/// <summary>
61+
/// Framework use only.
62+
/// </summary>
5963
public static readonly DependencyProperty HintVisibilityProperty = DependencyProperty.RegisterAttached(
6064
"HintVisibility", typeof(Visibility), typeof(PasswordFieldAssist), new PropertyMetadata(default(Visibility)));
6165

66+
/// <summary>
67+
/// Framework use only.
68+
/// </summary>
6269
public static void SetHintVisibility(DependencyObject element, Visibility value)
6370
{
6471
element.SetValue(HintVisibilityProperty, value);
6572
}
6673

74+
/// <summary>
75+
/// Framework use only.
76+
/// </summary>
6777
public static Visibility GetHintVisibility(DependencyObject element)
6878
{
6979
return (Visibility)element.GetValue(HintVisibilityProperty);
7080
}
7181

82+
/// <summary>
83+
/// Framework use only.
84+
/// </summary>
85+
/// <param name="element"></param>
86+
/// <param name="value"></param>
7287
public static void SetManaged(DependencyObject element, PasswordBox value)
7388
{
7489
element.SetValue(ManagedProperty, value);
7590
}
7691

92+
/// <summary>
93+
/// Framework use only.
94+
/// </summary>
7795
public static PasswordBox GetManaged(DependencyObject element)
7896
{
7997
return (PasswordBox)element.GetValue(ManagedProperty);
8098
}
8199

100+
/// <summary>
101+
/// Framework use only.
102+
/// </summary>
82103
private static void SetIsNullOrEmpty(DependencyObject element, bool value)
83104
{
84105
element.SetValue(IsNullOrEmptyPropertyKey, value);
85106
}
86107

108+
/// <summary>
109+
/// Framework use only.
110+
/// </summary>
87111
public static bool GetIsNullOrEmpty(DependencyObject element)
88112
{
89113
return (bool)element.GetValue(IsNullOrEmptyProperty);
90114
}
91115
}
92-
93-
public static class ProgressBarAssist
94-
{
95-
96-
97-
}
116+
98117
}

MaterialDesignThemes.Wpf/Ripple.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,25 @@ public double RippleY
140140
{
141141
get { return (double)GetValue(RippleYProperty); }
142142
private set { SetValue(RippleYPropertyKey, value); }
143-
}
143+
}
144+
145+
/// <summary>
146+
/// The DependencyProperty for the RecognizesAccessKey property.
147+
/// Default Value: false
148+
/// </summary>
149+
public static readonly DependencyProperty RecognizesAccessKeyProperty =
150+
DependencyProperty.Register(
151+
"RecognizesAccessKey", typeof(bool), typeof(Ripple),
152+
new PropertyMetadata(default(bool)));
153+
154+
/// <summary>
155+
/// Determine if Ripple should use AccessText in its style
156+
/// </summary>
157+
public bool RecognizesAccessKey
158+
{
159+
get { return (bool)GetValue(RecognizesAccessKeyProperty); }
160+
set { SetValue(RecognizesAccessKeyProperty, value); }
161+
}
144162

145163
public override void OnApplyTemplate()
146164
{

MaterialDesignThemes.Wpf/TextFieldAssist.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public static class TextFieldAssist
5252
private static readonly DependencyProperty IsNullOrEmptyProperty =
5353
IsNullOrEmptyPropertyKey.DependencyProperty;
5454

55+
/// <summary>
56+
/// Framework use only.
57+
/// </summary>
58+
public static readonly DependencyProperty ManagedProperty = DependencyProperty.RegisterAttached(
59+
"Managed", typeof(TextBox), typeof(TextFieldAssist), new PropertyMetadata(default(TextBox), ManagedPropertyChangedCallback));
60+
5561
#endregion
5662

5763
#region Public Methods and Operators
@@ -132,6 +138,24 @@ public static string GetText(DependencyObject element)
132138
return (string)element.GetValue(TextProperty);
133139
}
134140

141+
/// <summary>
142+
/// Framework use only.
143+
/// </summary>
144+
public static void SetManaged(DependencyObject element, TextBox value)
145+
{
146+
element.SetValue(ManagedProperty, value);
147+
}
148+
149+
/// <summary>
150+
/// Framework use only.
151+
/// </summary>
152+
/// <param name="element"></param>
153+
/// <returns></returns>
154+
public static TextBox GetManaged(DependencyObject element)
155+
{
156+
return (TextBox) element.GetValue(ManagedProperty);
157+
}
158+
135159
#endregion
136160

137161
#region Methods
@@ -199,11 +223,44 @@ private static void TextPropertyChangedCallback(DependencyObject dependencyObjec
199223
else
200224
{
201225
frameworkElement.Loaded += (sender, args) => VisualStateManager.GoToState(frameworkElement, state, false);
226+
frameworkElement.IsVisibleChanged += (sender, args) => VisualStateManager.GoToState(frameworkElement, state, true);
202227
}
203228

204229
SetIsNullOrEmpty(dependencyObject, string.IsNullOrEmpty((dependencyPropertyChangedEventArgs.NewValue ?? "").ToString()));
205230
}
206231

232+
private static void ManagedPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
233+
{
234+
var textBox = dependencyPropertyChangedEventArgs.OldValue as TextBox;
235+
if (textBox != null)
236+
{
237+
textBox.IsVisibleChanged -= ManagedTextBoxOnIsVisibleChanged;
238+
}
239+
240+
textBox = dependencyPropertyChangedEventArgs.NewValue as TextBox;
241+
if (textBox != null)
242+
{
243+
textBox.IsVisibleChanged += ManagedTextBoxOnIsVisibleChanged;
244+
}
245+
}
246+
247+
private static void ManagedTextBoxOnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
248+
{
249+
var textBox = (TextBox)sender;
250+
251+
if (!textBox.IsVisible) return;
252+
253+
var state = string.IsNullOrEmpty(textBox.Text)
254+
? "MaterialDesignStateTextEmpty"
255+
: "MaterialDesignStateTextNotEmpty";
256+
257+
//yep, had to invoke post this to trigger refresh
258+
textBox.Dispatcher.BeginInvoke(new Action(() =>
259+
{
260+
VisualStateManager.GoToState(textBox, state, false);
261+
}));
262+
}
263+
207264
private static void SetIsNullOrEmpty(DependencyObject element, bool value)
208265
{
209266
element.SetValue(IsNullOrEmptyPropertyKey, value);

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<converters:DrawerOffsetConverter x:Key="DrawerOffsetConverter" />
3333

3434
<Style TargetType="{x:Type local:Ripple}">
35+
<Setter Property="RecognizesAccessKey" Value="True" />
3536
<Setter Property="HorizontalAlignment" Value="Stretch" />
3637
<Setter Property="VerticalAlignment" Value="Stretch" />
3738
<Setter Property="Background" Value="Transparent" />
@@ -133,11 +134,14 @@
133134
</Ellipse>
134135
</Canvas>
135136
<ContentPresenter Content="{TemplateBinding Content}"
137+
ContentStringFormat="{TemplateBinding ContentStringFormat}"
136138
ContentTemplate="{TemplateBinding ContentTemplate}"
137139
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
138140
Margin="{TemplateBinding Padding}"
139141
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
140-
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
142+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
143+
RecognizesAccessKey="{TemplateBinding RecognizesAccessKey}"
144+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
141145
</Grid>
142146
</ControlTemplate>
143147
</Setter.Value>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.CheckBox.xaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
<Style x:Key="MaterialDesignCheckBox" TargetType="{x:Type CheckBox}">
4848
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
4949
<Setter Property="BorderThickness" Value="1"/>
50+
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
51+
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
5052
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
5153
<Setter Property="Template">
5254
<Setter.Value>
@@ -114,7 +116,7 @@
114116
<Trigger Property="IsPressed" Value="true"/>
115117
<Trigger Property="IsChecked" Value="true">
116118
<Setter Property="Data" TargetName="Graphic" Value="M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z" />
117-
<Setter Property="Fill" TargetName="Graphic" Value="{DynamicResource PrimaryHueMidBrush}" />
119+
<Setter Property="Fill" TargetName="Graphic" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}" />
118120
</Trigger>
119121
<Trigger Property="IsChecked" Value="{x:Null}">
120122
<Setter Property="Data" TargetName="Graphic" Value="M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z" />
@@ -126,6 +128,24 @@
126128
</Setter>
127129
</Style>
128130

131+
<Style x:Key="MaterialDesignLightCheckBox" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}">
132+
<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
133+
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
134+
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
135+
</Style>
136+
137+
<Style x:Key="MaterialDesignDarkCheckBox" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}">
138+
<Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
139+
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueDarkBrush}"/>
140+
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
141+
</Style>
142+
143+
<Style x:Key="MaterialDesignAccentCheckBox" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}">
144+
<Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
145+
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
146+
<Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
147+
</Style>
148+
129149
<Style x:Key="MaterialDesignUserForegroundCheckBox" TargetType="{x:Type CheckBox}">
130150
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
131151
<Setter Property="BorderThickness" Value="1"/>
@@ -206,4 +226,4 @@
206226
</Setter>
207227
</Style>
208228

209-
</ResourceDictionary>
229+
</ResourceDictionary>

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.PasswordBox.xaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<Setter Property="Background" Value="Transparent"/>
1717
<Setter Property="CaretBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderBrush}"/>
1818
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
19-
<Setter Property="HorizontalContentAlignment" Value="Left"/>
20-
<Setter Property="VerticalContentAlignment" Value="Center"/>
19+
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
20+
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
2121
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
2222
<Setter Property="AllowDrop" Value="true"/>
2323
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
@@ -27,23 +27,23 @@
2727
<Setter Property="Template">
2828
<Setter.Value>
2929
<ControlTemplate TargetType="{x:Type PasswordBox}">
30-
<Grid VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
30+
<Grid>
3131
<Border x:Name="border"
3232
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
3333
Background="{TemplateBinding Background}"
3434
SnapsToDevicePixels="True"
35-
Padding="0 4 0 4" VerticalAlignment="Center">
36-
<Grid Margin="{TemplateBinding Padding}">
37-
<ScrollViewer x:Name="PART_ContentHost"
38-
Focusable="false"
39-
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"
40-
TextElement.FontFamily="Times New Roman" />
35+
Padding="0 4 0 4">
36+
<Grid Margin="{TemplateBinding Padding}"
37+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
38+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
39+
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"
40+
/>
4141
<TextBlock Text="{Binding Path=(wpf:TextFieldAssist.Hint), RelativeSource={RelativeSource TemplatedParent}}"
42-
Visibility="{Binding Path=(wpf:PasswordFieldAssist.HintVisibility), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
43-
Margin="1 0 1 0"
42+
Visibility="{Binding Path=(wpf:PasswordFieldAssist.HintVisibility), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
4443
IsHitTestVisible="False"
45-
x:Name="Hint"
46-
Opacity="{Binding Path=(wpf:TextFieldAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}" />
44+
x:Name="Hint"
45+
Margin="1 0 1 0"
46+
Opacity="{Binding Path=(wpf:TextFieldAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}" />
4747
</Grid>
4848
</Border>
4949
<wpf:Underline x:Name="Underline"/>

0 commit comments

Comments
 (0)