Skip to content

Commit 8b62ab4

Browse files
Update Calendar to specs for more customization (#2356)
* Add new Calendar Properties * Removing default values Co-authored-by: Kevin Bost <[email protected]>
1 parent c6b398d commit 8b62ab4

File tree

3 files changed

+167
-66
lines changed

3 files changed

+167
-66
lines changed
Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,62 @@
11
using System.Windows;
2+
using System.Windows.Media;
23

34
namespace MaterialDesignThemes.Wpf
45
{
6+
public enum CalendarOrientation
7+
{
8+
Vertical,
9+
Horizontal
10+
}
511
public static class CalendarAssist
612
{
13+
#region Header Visibility
714
public static readonly DependencyProperty IsHeaderVisibleProperty = DependencyProperty.RegisterAttached(
815
"IsHeaderVisible", typeof(bool), typeof(CalendarAssist), new PropertyMetadata(true));
916

10-
public static void SetIsHeaderVisible(DependencyObject element, bool value) => element.SetValue(IsHeaderVisibleProperty, value);
1117
public static bool GetIsHeaderVisible(DependencyObject element) => (bool)element.GetValue(IsHeaderVisibleProperty);
18+
public static void SetIsHeaderVisible(DependencyObject element, bool value) => element.SetValue(IsHeaderVisibleProperty, value);
19+
#endregion
20+
21+
#region HeaderBackground
22+
23+
public static readonly DependencyProperty HeaderBackgroundProperty = DependencyProperty.RegisterAttached(
24+
"HeaderBackground", typeof(Brush), typeof(CalendarAssist), new FrameworkPropertyMetadata(default(Brush)));
25+
26+
public static Brush GetHeaderBackground(DependencyObject element) => (Brush)element.GetValue(HeaderBackgroundProperty);
27+
public static void SetHeaderBackground(DependencyObject element, Brush value) => element.SetValue(HeaderBackgroundProperty, value);
28+
#endregion
29+
30+
#region HeaderForeground
31+
public static readonly DependencyProperty HeaderForegroundProperty = DependencyProperty.RegisterAttached(
32+
"HeaderForeground", typeof(Brush), typeof(CalendarAssist), new FrameworkPropertyMetadata(default(Brush)));
33+
34+
public static Brush GetHeaderForeground(DependencyObject element) => (Brush)element.GetValue(HeaderForegroundProperty);
35+
public static void SetHeaderForeground(DependencyObject element, Brush value) => element.SetValue(HeaderForegroundProperty, value);
36+
#endregion
37+
38+
#region SelectionColor
39+
public static readonly DependencyProperty SelectionColorProperty = DependencyProperty.RegisterAttached(
40+
"SelectionColor", typeof(Brush), typeof(CalendarAssist), new FrameworkPropertyMetadata(default(Brush)));
41+
42+
public static Brush GetSelectionColor(DependencyObject element) => (Brush)element.GetValue(SelectionColorProperty);
43+
public static void SetSelectionColor(DependencyObject element, Brush value) => element.SetValue(SelectionColorProperty, value);
44+
#endregion
45+
46+
#region SelectionForegroundColor
47+
public static readonly DependencyProperty SelectionForegroundColorProperty = DependencyProperty.RegisterAttached(
48+
"SelectionForegroundColor", typeof(Brush), typeof(CalendarAssist), new FrameworkPropertyMetadata(default(Brush)));
49+
50+
public static Brush GetSelectionForegroundColor(DependencyObject element) => (Brush)element.GetValue(SelectionForegroundColorProperty);
51+
public static void SetSelectionForegroundColor(DependencyObject element, Brush value) => element.SetValue(SelectionForegroundColorProperty, value);
52+
#endregion
53+
54+
#region Orientation
55+
public static readonly DependencyProperty OrientationProperty = DependencyProperty.RegisterAttached(
56+
"Orientation", typeof(CalendarOrientation), typeof(CalendarAssist), new FrameworkPropertyMetadata(default(CalendarOrientation)));
57+
58+
public static CalendarOrientation GetOrientation(DependencyObject element) => (CalendarOrientation)element.GetValue(OrientationProperty);
59+
public static void SetOrientation(DependencyObject element, CalendarOrientation value) => element.SetValue(OrientationProperty, value);
60+
#endregion
1261
}
1362
}

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:local="clr-namespace:MaterialDesignThemes.Wpf"
55
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
66
xmlns:transitions="clr-namespace:MaterialDesignThemes.Wpf.Transitions"
7-
xmlns:system="clr-namespace:System;assembly=mscorlib">
7+
xmlns:system="clr-namespace:System;assembly=mscorlib"
8+
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
89

910
<ResourceDictionary.MergedDictionaries>
1011
<!-- we only bring in the dictionaries for controls which were "invented"
@@ -278,8 +279,8 @@
278279
FontSize="15" FontWeight="Normal" />
279280
<StackPanel x:Name="ComponentOneTwoWrapper" Orientation="Horizontal"
280281
HorizontalAlignment="Left">
281-
<TextBlock Text="{TemplateBinding ComponentTwoContent}" FontSize="30" FontWeight="Normal" />
282-
<TextBlock Text="{TemplateBinding ComponentOneContent}" Margin="10 0 0 0" FontSize="30" FontWeight="Normal" />
282+
<TextBlock Text="{TemplateBinding ComponentTwoContent}" Margin="0 0 10 0" FontSize="30" FontWeight="Normal"/>
283+
<TextBlock Text="{TemplateBinding ComponentOneContent}" FontSize="30" FontWeight="Normal"/>
283284
</StackPanel>
284285
</StackPanel>
285286
</Border>
@@ -291,6 +292,9 @@
291292
<Setter TargetName="ComponentThreeTextBlock" Property="Opacity" Value="1"/>
292293
<Setter TargetName="ComponentOneTwoWrapper" Property="Opacity" Value=".56"/>
293294
</Trigger>
295+
<Trigger Property="wpf:CalendarAssist.Orientation" Value="Horizontal">
296+
<Setter TargetName="ComponentOneTwoWrapper" Property="Orientation" Value="Vertical"/>
297+
</Trigger>
294298
</ControlTemplate.Triggers>
295299
</ControlTemplate>
296300
</Setter.Value>

0 commit comments

Comments
 (0)