private static void OnLabelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MaterialComboBox box = d as MaterialComboBox;

            if (box != null && box.inputLabel != null)
            {
                box.inputLabel.Text = box.Label;
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.errorLabel = (TextBlock)GetTemplateChild("PART_ErrorLabel");
            this.panel      = (StackPanel)GetTemplateChild("PART_Panel");

            switch (this.DateFormat)
            {
            case DateFormat.DayMonthYear:
                this.boxDay   = (MaterialComboBox)GetTemplateChild("PART_Box1");
                this.boxMonth = (MaterialComboBox)GetTemplateChild("PART_Box2");
                this.boxYear  = (MaterialComboBox)GetTemplateChild("PART_Box3");
                break;

            case DateFormat.MonthDayYear:
                this.boxMonth = (MaterialComboBox)GetTemplateChild("PART_Box1");
                this.boxDay   = (MaterialComboBox)GetTemplateChild("PART_Box2");
                this.boxYear  = (MaterialComboBox)GetTemplateChild("PART_Box3");
                break;

            case DateFormat.YearMonthDay:
                this.boxYear  = (MaterialComboBox)GetTemplateChild("PART_Box1");
                this.boxMonth = (MaterialComboBox)GetTemplateChild("PART_Box2");
                this.boxDay   = (MaterialComboBox)GetTemplateChild("PART_Box3");
                break;

            case DateFormat.YearDayMonth:
                this.boxYear  = (MaterialComboBox)GetTemplateChild("PART_Box1");
                this.boxDay   = (MaterialComboBox)GetTemplateChild("PART_Box2");
                this.boxMonth = (MaterialComboBox)GetTemplateChild("PART_Box3");
                break;

            default:
                break;
            }

            this.errorLabel.FontSize = this.GetSmallFontSize();
            this.errorLabel.Margin   = this.ValidationMode.Equals(ValidationMode.None) ? new Thickness(0) : new Thickness(0, this.GetMargin(), 0, 0);
            this.panel.Margin        = this.IsFloating ? new Thickness(0, this.GetSmallFontSize() + this.GetMargin(), 0, 0) : new Thickness(0);

            this.boxDay.Label   = this.LabelDay;
            this.boxMonth.Label = this.LabelMonth;
            this.boxYear.Label  = this.LabelYear;

            this.boxDay.ItemsSource   = this.Days();
            this.boxMonth.ItemsSource = this.Months();
            this.boxYear.ItemsSource  = this.Years();

            this.boxDay.SelectionChanged   += BoxDay_SelectionChanged;
            this.boxMonth.SelectionChanged += BoxMonth_SelectionChanged;
            this.boxYear.SelectionChanged  += BoxYear_SelectionChanged;
        }
        private void BoxYear_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (sender is MaterialComboBox)
            {
                MaterialComboBox box = (MaterialComboBox)sender;

                if (box.SelectedItem is int)
                {
                    this.Year = (int)box.SelectedItem;
                    this.Validate();
                }
            }
        }