Next to the WPF Calendar control manufacturing Process Analysis (1) Define Header
In the header, we saw the definition of a custom style TitleStyle
1. Custom Style
See Background code Definition
Code
/**//// <summary>
/// The DependencyProperty for the TitleStyle property.
/// Flags: none
/// Default Value: null
/// </summary>
public static readonly DependencyProperty TitleStyleProperty =
DependencyProperty.Register(
"TitleStyle",
typeof(Style),
typeof(MonthCalendar),
new FrameworkPropertyMetadata(
(Style)null));
/**//// <summary>
/// TitleStyle property
/// </summary>
public Style TitleStyle
{
get { return (Style)GetValue(TitleStyleProperty); }
set { SetValue(TitleStyleProperty, value); }
}
It should be said to be simpler, the default style is null, and if a style is specified, the default style is overwritten
2. Do not overlap selection style
Define two styles for the forward and rewind buttons for the calendar
Code
/**////<summary>
///The DependencyProperty for the Previousbuttonstyle property.
///Flags:none
///Default value:null
///</summary>
public static readonly DependencyProperty Previousbuttonstyleproperty =
Dependencyproperty.register (
"Previousbuttonstyle",
typeof (Style),
typeof (MonthCalendar),
New Frameworkpropertymetadata (
(Style) NULL, new Propertychangedcallback (onpreviousbuttonstylechanged)));
/**////<summary>
///Previousbuttonstyle Property
///</summary>
Public Style Previousbuttonstyle
{
get {return (Style) GetValue (Previousbuttonstyleproperty);}
set {SetValue (Previousbuttonstyleproperty, value);}
}
private static void Onpreviousbuttonstylechanged (DependencyObject D, DependencyPropertyChangedEventArgs e)
{
((MonthCalendar) d). Refreshpreviousbuttonstyle ();
}
/**////<summary>
///The DependencyProperty for the Nextbuttonstyle property.
///Flags:none
///Default value:null
///</summary>
public static readonly DependencyProperty Nextbuttonstyleproperty =
Dependencyproperty.register (
"Nextbuttonstyle",
typeof (Style),
typeof (MonthCalendar),
New Frameworkpropertymetadata (
(Style) NULL, new Propertychangedcallback (onnextbuttonstylechanged)));
/**////<summary>
///Nextbuttonstyle Property
///</summary>
Public Style Nextbuttonstyle
{
get {return (Style) GetValue (Nextbuttonstyleproperty);}
set {SetValue (Nextbuttonstyleproperty, value);}
}
private static void Onnextbuttonstylechanged (DependencyObject D, DependencyPropertyChangedEventArgs e)
{
((MonthCalendar) d). Refreshnextbuttonstyle ();
}