Exemple #1
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var uc = (this.Parent as FrameworkElement).FindParent <UserControl>();

            if (uc == null)
            {
                return;
            }

            var dtStartObject = uc.FindName(DateStart);

            if (dtStartObject is Xceed.Wpf.Controls.DatePicker)
            {
                dateStart = dtStartObject as Xceed.Wpf.Controls.DatePicker;
                dateEnd   = uc.FindName(DateEnd) as Xceed.Wpf.Controls.DatePicker;
            }
            else if (dtStartObject is DateControl)
            {
                dateStart = (dtStartObject as DateControl).dpDate;
                dateEnd   = (uc.FindName(DateEnd) as DateControl).dpDate;
            }
            else if (dtStartObject is DateTimeControl)
            {
                dateStart = (dtStartObject as DateTimeControl).dpDate;
                dateEnd   = (uc.FindName(DateEnd) as DateTimeControl).dpDate;
            }
            else if (dtStartObject is MonthYear)
            {
                myDateStart = dtStartObject as MonthYear;
                myDateEnd   = uc.FindName(DateEnd) as MonthYear;
            }

            timeStart = uc.FindName(TimeStart) as ComboBox;
            timeEnd   = uc.FindName(TimeEnd) as ComboBox;
        }
Exemple #2
0
        protected override void OnPreviewLostKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e)
        {
            base.OnPreviewLostKeyboardFocus(e);

            Xceed.Wpf.Controls.NavigableComboBox navCombo = ((Xceed.Wpf.Controls.NavigableComboBox)((System.Windows.Controls.Decorator)(this.GetVisualChild(0))).Child);

            Xceed.Wpf.Controls.DatePicker innerDP = (Xceed.Wpf.Controls.DatePicker)navCombo.Template.FindName("textInput", navCombo);

            Xceed.Wpf.Controls.DateTimeTextBox innerText = (Xceed.Wpf.Controls.DateTimeTextBox)innerDP.Template.FindName("PART_DatePickerFocusRoot", innerDP);

            if (innerText.HasParsingError)
            {
                innerText.Text = "";

                if (this.BorderBrush != Brushes.Red)
                {
                    _normalBrush = this.BorderBrush;
                }

                this.BorderBrush = Brushes.Red;

                _errorSet = true;
            }
            else
            {
                if (_errorSet)
                {
                    _errorSet = false;
                }
                else
                {
                    if (this.BorderBrush == Brushes.Red)
                    {
                        this.BorderBrush = _normalBrush;
                    }
                }
            }
        }