WPF Calendar Control manufacturing Process Analysis (2) Custom style properties

Source: Internet
Author: User
Tags header

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

/**////&lt;summary&gt;


///The DependencyProperty for the Previousbuttonstyle property.


///Flags:none


///Default value:null


///&lt;/summary&gt;


public static readonly DependencyProperty Previousbuttonstyleproperty =


Dependencyproperty.register (


"Previousbuttonstyle",


typeof (Style),


typeof (MonthCalendar),


New Frameworkpropertymetadata (


(Style) NULL, new Propertychangedcallback (onpreviousbuttonstylechanged)));





/**////&lt;summary&gt;


///Previousbuttonstyle Property


///&lt;/summary&gt;


Public Style Previousbuttonstyle


     {


get {return (Style) GetValue (Previousbuttonstyleproperty);}


set {SetValue (Previousbuttonstyleproperty, value);}


     }





private static void Onpreviousbuttonstylechanged (DependencyObject D, DependencyPropertyChangedEventArgs e)


     {


((MonthCalendar) d). Refreshpreviousbuttonstyle ();


     }





/**////&lt;summary&gt;


///The DependencyProperty for the Nextbuttonstyle property.


///Flags:none


///Default value:null


///&lt;/summary&gt;


public static readonly DependencyProperty Nextbuttonstyleproperty =


Dependencyproperty.register (


"Nextbuttonstyle",


typeof (Style),


typeof (MonthCalendar),


New Frameworkpropertymetadata (


(Style) NULL, new Propertychangedcallback (onnextbuttonstylechanged)));





/**////&lt;summary&gt;


///Nextbuttonstyle Property


///&lt;/summary&gt;


Public Style Nextbuttonstyle


     {


get {return (Style) GetValue (Nextbuttonstyleproperty);}


set {SetValue (Nextbuttonstyleproperty, value);}


     }





private static void Onnextbuttonstylechanged (DependencyObject D, DependencyPropertyChangedEventArgs e)


     {


((MonthCalendar) d). Refreshnextbuttonstyle ();


     }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.