Skip to content

Commit 61d435c

Browse files
committed
Change according to material design spec
https://www.google.com/design/spec/components/pickers.html
1 parent 7b060c6 commit 61d435c

File tree

5 files changed

+70
-58
lines changed

5 files changed

+70
-58
lines changed

MaterialDesignThemes.Wpf/MaterialDateDisplay.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class MaterialDateDisplay : Control
2222
private readonly IDictionary<char, string> _formats = new Dictionary<char, string>
2323
{
2424
{'d', "dd"},
25-
{'m', "MMM"},
25+
{'m', "ddd, MMM"},
2626
{'y', "yyyy"}
2727
};
2828

@@ -122,7 +122,7 @@ private void UpdateComponents()
122122
{
123123
if (component.index == 0)
124124
IsDayInFirstComponent = component.code == 'd';
125-
_setters[component.index](DisplayDate.ToString(_formats[component.code], CultureInfo.CurrentUICulture).ToUpper());
125+
_setters[component.index](DisplayDate.ToString(_formats[component.code], CultureInfo.CurrentUICulture).ToTitleCase());
126126
}
127127
}
128128

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@
250250
<Compile Include="RatingBar.cs" />
251251
<Compile Include="RatingBarButton.cs" />
252252
<Compile Include="ShadowAssist.cs" />
253+
<Compile Include="StringExtensions.cs" />
253254
<Compile Include="TextFieldAssist.cs" />
254255
<Compile Include="Converters\TextFieldHintVisibilityConverter.cs" />
255256
<Compile Include="TimePicker.cs" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace MaterialDesignThemes.Wpf
9+
{
10+
internal static class StringExtensions
11+
{
12+
public static string ToTitleCase(this string text, string separator = " ")
13+
{
14+
TextInfo textInfo = CultureInfo.CurrentUICulture.TextInfo;
15+
16+
string lowerText = textInfo.ToLower(text);
17+
string[] words = lowerText.Split(new[] { separator }, StringSplitOptions.None);
18+
19+
return String.Join(separator, words.Select(v => textInfo.ToTitleCase(v)));
20+
}
21+
}
22+
}

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -202,34 +202,33 @@
202202
<Border Background="{TemplateBinding Background}"
203203
BorderBrush="{TemplateBinding BorderBrush}"
204204
BorderThickness="{TemplateBinding BorderThickness}">
205-
<StackPanel>
206-
<TextBlock Text="{TemplateBinding ComponentOneContent}" HorizontalAlignment="Center" Margin="0 12 0 0" FontSize="24" FontWeight="Normal" />
207-
<TextBlock Text="{TemplateBinding ComponentTwoContent}" HorizontalAlignment="Center" Margin="0 -6 0 0" FontSize="60" FontWeight="Normal" />
208-
<TextBlock Text="{TemplateBinding ComponentThreeContent}" HorizontalAlignment="Center" Margin="0 -4 0 10" FontSize="24" Opacity=".56" FontWeight="Normal" />
205+
<StackPanel Orientation="Vertical"
206+
Margin="0">
207+
<TextBlock x:Name="ComponentThreeTextBlock"
208+
Text="{TemplateBinding ComponentThreeContent}"
209+
HorizontalAlignment="Left"
210+
FontSize="15" FontWeight="Normal" />
211+
<StackPanel x:Name="ComponentOneTwoWrapper" Orientation="Horizontal"
212+
HorizontalAlignment="Left">
213+
<TextBlock Text="{TemplateBinding ComponentTwoContent}" FontSize="30" FontWeight="Normal" />
214+
<TextBlock Text="{TemplateBinding ComponentOneContent}" Margin="10 0 0 0" FontSize="30" FontWeight="Normal" />
215+
</StackPanel>
209216
</StackPanel>
210217
</Border>
218+
<ControlTemplate.Triggers>
219+
<Trigger Property="IsDayInFirstComponent" Value="True">
220+
<Setter TargetName="ComponentThreeTextBlock" Property="Opacity" Value=".56"/>
221+
</Trigger>
222+
<Trigger Property="IsEnabled" Value="False">
223+
<Setter TargetName="ComponentThreeTextBlock" Property="Opacity" Value="1"/>
224+
<Setter TargetName="ComponentOneTwoWrapper" Property="Opacity" Value=".56"/>
225+
</Trigger>
226+
</ControlTemplate.Triggers>
211227
</ControlTemplate>
212228
</Setter.Value>
213229
</Setter>
214230
<Style.Triggers>
215-
<Trigger Property="IsDayInFirstComponent" Value="True">
216-
<Setter Property="Template">
217-
<Setter.Value>
218-
<ControlTemplate TargetType="{x:Type local:MaterialDateDisplay}">
219-
<Border Background="{TemplateBinding Background}"
220-
BorderBrush="{TemplateBinding BorderBrush}"
221-
BorderThickness="{TemplateBinding BorderThickness}">
222-
<StackPanel>
223-
<TextBlock Text="{TemplateBinding ComponentOneContent}" HorizontalAlignment="Center" Margin="0 4 0 0" FontSize="60" FontWeight="Normal" />
224-
<TextBlock Text="{TemplateBinding ComponentTwoContent}" HorizontalAlignment="Center" Margin="0 -4 0 0" FontSize="24" FontWeight="Normal" />
225-
<TextBlock Text="{TemplateBinding ComponentThreeContent}" HorizontalAlignment="Center" Margin="0 4 0 10" FontSize="24" Opacity=".56" FontWeight="Normal" />
226-
</StackPanel>
227-
</Border>
228-
</ControlTemplate>
229-
</Setter.Value>
230-
</Setter>
231-
</Trigger>
232-
</Style.Triggers>
231+
</Style.Triggers>
233232
</Style>
234233

235234
<Style TargetType="{x:Type local:ListSortDirectionIndicator}">

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.Calendar.xaml

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
<VisualState x:Name="Selected">
4949
<Storyboard>
5050
<DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="SelectedBackground"/>
51-
<!--ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground)" Storyboard.TargetName="NormalText">
51+
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground)" Storyboard.TargetName="NormalText">
5252
<DiscreteObjectKeyFrame Value="{DynamicResource PrimaryHueMidForegroundBrush}" KeyTime="0" />
53-
</-->
53+
</ObjectAnimationUsingKeyFrames>
5454
</Storyboard>
5555
</VisualState>
5656
</VisualStateGroup>
@@ -100,9 +100,9 @@
100100
<VisualState x:Name="Today">
101101
<Storyboard>
102102
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="TodayBackground"/>
103-
<!--ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground)" Storyboard.TargetName="NormalText">
103+
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground)" Storyboard.TargetName="NormalText">
104104
<DiscreteObjectKeyFrame Value="{DynamicResource PrimaryHueLightForegroundBrush}" KeyTime="0" />
105-
</-->
105+
</ObjectAnimationUsingKeyFrames>
106106
</Storyboard>
107107
</VisualState>
108108
</VisualStateGroup>
@@ -288,6 +288,7 @@
288288

289289
<DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
290290
<TextBlock Foreground="{DynamicResource MaterialDesignToolTipBackground}"
291+
Opacity="0.65"
291292
FontWeight="Bold"
292293
FontSize="9.5"
293294
FontFamily="Verdana"
@@ -360,14 +361,11 @@
360361
<VisualStateGroup x:Name="CommonStates">
361362
<VisualState x:Name="Normal"/>
362363
<VisualState x:Name="MouseOver" />
363-
<VisualState x:Name="Disabled">
364-
<Storyboard>
365-
<DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="buttonContent"/>
366-
</Storyboard>
367-
</VisualState>
364+
<VisualState x:Name="Disabled"/>
368365
</VisualStateGroup>
369366
</VisualStateManager.VisualStateGroups>
370-
<wpf:MaterialDateDisplay x:Name="buttonContent" Foreground="{DynamicResource PrimaryHueMidForegroundBrush}">
367+
<wpf:MaterialDateDisplay x:Name="buttonContent" Foreground="{DynamicResource PrimaryHueMidForegroundBrush}"
368+
IsEnabled="{TemplateBinding IsEnabled}">
371369
<wpf:MaterialDateDisplay.DisplayDate>
372370
<MultiBinding Mode="OneWay">
373371
<MultiBinding.Converter>
@@ -385,51 +383,42 @@
385383
<ColumnDefinition Width="Auto"/>
386384
<ColumnDefinition Width="Auto"/>
387385
<ColumnDefinition Width="Auto"/>
388-
<ColumnDefinition Width="Auto"/>
389386
</Grid.ColumnDefinitions>
390387
<Grid.RowDefinitions>
391388
<RowDefinition Height="Auto"/>
392389
<RowDefinition Height="Auto"/>
393390
<RowDefinition Height="Auto"/>
394391
<RowDefinition Height="*"/>
395392
</Grid.RowDefinitions>
396-
<Border Grid.ColumnSpan="3" Grid.Row="0" Background="{DynamicResource PrimaryHueDarkBrush}" CornerRadius="2 2 0 0">
397-
<TextBlock HorizontalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="8" FontSize="14">
398-
<TextBlock.Text>
399-
<MultiBinding Mode="OneWay" StringFormat="dddd" ConverterCulture="{x:Static globalization:CultureInfo.CurrentUICulture}" >
400-
<MultiBinding.Converter>
401-
<converters:CalendarDateCoalesceConverter />
402-
</MultiBinding.Converter>
403-
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Calendar}}" Path="DisplayDate" />
404-
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Calendar}}" Path="SelectedDate" />
405-
</MultiBinding>
406-
</TextBlock.Text>
407-
</TextBlock>
408-
</Border>
409-
<Border Grid.ColumnSpan="3" Grid.Row="1" Background="{DynamicResource PrimaryHueMidBrush}" />
410-
<Button x:Name="PART_HeaderButton" Grid.Row="1" Grid.Column="1" FontWeight="Bold" Focusable="False" FontSize="10.5" HorizontalAlignment="Center" Template="{StaticResource HeaderButtonTemplate}" VerticalAlignment="Center"
411-
Height="142"
412-
/>
413-
<Button x:Name="PART_PreviousButton" Grid.Row="2" Grid.Column="0" Focusable="False" HorizontalAlignment="Left" Height="36" Template="{StaticResource PreviousButtonTemplate}" Width="32"
393+
<Border Grid.ColumnSpan="3" Grid.Row="0" Background="{DynamicResource PrimaryHueMidBrush}" />
394+
<Button x:Name="PART_HeaderButton"
395+
Grid.Row="0"
396+
Grid.ColumnSpan="3"
397+
FontWeight="Bold" Focusable="False" FontSize="10.5"
398+
HorizontalAlignment="Left" VerticalAlignment="Center"
399+
Template="{StaticResource HeaderButtonTemplate}"
400+
Height="Auto"
401+
Margin="20 15"/>
402+
<Button x:Name="PART_PreviousButton" Grid.Row="1" Grid.Column="0" Focusable="False" HorizontalAlignment="Left" Height="36" Template="{StaticResource PreviousButtonTemplate}" Width="32"
414403
Margin="6 0 0 0" Foreground="{TemplateBinding Foreground}" />
415404
<TextBlock x:Name="CurrentDateTextBlock"
416405
HorizontalAlignment="Center" VerticalAlignment="Center"
417406
Margin="8"
418407
FontSize="14"
419-
Grid.Row="2" Grid.Column="1"
408+
Grid.Row="1" Grid.Column="1"
420409
FontWeight="SemiBold"
421410
RenderTransformOrigin="0, 0.5"
422411
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}, Path=DisplayDate, ConverterCulture={x:Static globalization:CultureInfo.CurrentUICulture}, StringFormat=MMMM yyyy}">
423412
<TextBlock.RenderTransform>
424413
<TranslateTransform X="0" Y="0"/>
425414
</TextBlock.RenderTransform>
426415
</TextBlock>
427-
<Button x:Name="PART_NextButton" Grid.Row="2" Grid.Column="2" Focusable="False" HorizontalAlignment="Right" Height="36" Template="{StaticResource NextButtonTemplate}" Width="32"
416+
<Button x:Name="PART_NextButton" Grid.Row="1" Grid.Column="2" Focusable="False" HorizontalAlignment="Right" Height="36" Template="{StaticResource NextButtonTemplate}" Width="32"
428417
Margin="0 0 6 0" Foreground="{TemplateBinding Foreground}" />
429418

430419
<Grid x:Name="MonthViewWrapperGrid"
431420
Grid.ColumnSpan="3"
432-
Grid.Row="3"
421+
Grid.Row="2"
433422
HorizontalAlignment="Center"
434423
VerticalAlignment="Top"
435424
Margin="6 -1 6 6"
@@ -470,7 +459,7 @@
470459

471460
<Grid x:Name="YearViewWrapperGrid"
472461
Grid.ColumnSpan="3"
473-
Grid.Row="3"
462+
Grid.Row="2"
474463
HorizontalAlignment="Center"
475464
VerticalAlignment="Top"
476465
Margin="6 -3 7 6"
@@ -484,7 +473,8 @@
484473
<TranslateTransform X="0"/>
485474
</Border.RenderTransform>
486475
</Border>
487-
<Grid x:Name="PART_YearView" RenderTransformOrigin="0, 0.5">
476+
<Grid x:Name="PART_YearView"
477+
RenderTransformOrigin="0, 0.5">
488478
<Grid.RenderTransform>
489479
<TranslateTransform X="0" />
490480
</Grid.RenderTransform>

0 commit comments

Comments
 (0)