-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExtendedCalendar.cs
More file actions
86 lines (71 loc) · 2.25 KB
/
ExtendedCalendar.cs
File metadata and controls
86 lines (71 loc) · 2.25 KB
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
namespace Menees.Windows.Presentation
{
#region Using Directives
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
#endregion
/// <summary>
/// Extends the standard WPF Calendar control to support variable control
/// sizes, fonts, and system colors.
/// </summary>
public sealed class ExtendedCalendar : Calendar
{
#region Public Fields
/// <summary>
/// The dependency property backing field for the <see cref="HeaderBrush"/> property.
/// </summary>
public static readonly DependencyProperty HeaderBrushProperty =
DependencyProperty.Register(
nameof(HeaderBrush),
typeof(Brush),
typeof(ExtendedCalendar),
new PropertyMetadata(SystemColors.GradientInactiveCaptionBrush));
#endregion
#region Constructors
static ExtendedCalendar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ExtendedCalendar), new FrameworkPropertyMetadata(typeof(ExtendedCalendar)));
}
#endregion
#region Public Properties
/// <summary>
/// Gets or sets the brush to use for the header background.
/// </summary>
public Brush HeaderBrush
{
get { return (Brush)this.GetValue(HeaderBrushProperty); }
set { this.SetValue(HeaderBrushProperty, value); }
}
#endregion
#region Protected Methods
/// <summary>
/// Works around a bug in the WPF Calendar control where it fails to correctly release the mouse capture.
/// </summary>
protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
{
// The stupid Calendar control can capture the mouse and keep it too long, which makes
// users have to click twice to get focus out of the control and on to another control.
// http://stackoverflow.com/questions/2425951/wpf-toolkit-calendar-takes-two-clicks-to-get-focus
base.OnPreviewMouseUp(e);
if (Mouse.Captured is CalendarItem)
{
Mouse.Capture(null);
}
}
#endregion
}
}