private void InitializeEnums() { Binding bnd = new Binding("FullMonthNames"); bnd.Source = Scheduler.CalendarHelper; YearlyDetails12.SetBinding(ItemsControl.ItemsSourceProperty, bnd); YearlyDetails23.SetBinding(ItemsControl.ItemsSourceProperty, bnd); bnd = new Binding("MonthOfYear"); bnd.Source = _pattern; bnd.Mode = BindingMode.TwoWay; bnd.Converter = DecrementConverter.Default; YearlyDetails12.SetBinding(ComboBox.SelectedIndexProperty, bnd); YearlyDetails23.SetBinding(ComboBox.SelectedIndexProperty, bnd); }
private void ValidateYearly() { if (IsValidDayMonth()) { PART_DialogOkButton.IsEnabled = true; YearlyDetails12.ClearValue(Control.ForegroundProperty); YearlyDetails12.ClearValue(Control.BorderBrushProperty); YearlyDetails12.ClearValue(Control.BorderThicknessProperty); YearlyDetails12.ClearValue(ToolTipService.ToolTipProperty); YearlyDetails11.ClearValue(Control.ForegroundProperty); YearlyDetails11.ClearValue(Control.BorderBrushProperty); YearlyDetails11.ClearValue(Control.BorderThicknessProperty); YearlyDetails11.ClearValue(ToolTipService.ToolTipProperty); } else { PART_DialogOkButton.IsEnabled = false; YearlyDetails11.BorderBrush = YearlyDetails12.BorderBrush = YearlyDetails11.Foreground = YearlyDetails12.Foreground = new SolidColorBrush(Colors.Red); YearlyDetails11.BorderThickness = YearlyDetails12.BorderThickness = new Thickness(2); int max = 31; int month = YearlyDetails12.SelectedIndex + 1; if (month == 4 || month == 6 || month == 9 || month == 11) { max = 30; } if (month == 2) { max = 29; } string error = String.Format(C1Localizer.GetString("ValidationErrors", "NumberIsOutOfRange", "Please enter value in the range: {0}."), (string)("1 - " + max)); ToolTipService.SetToolTip(YearlyDetails12, error); ToolTipService.SetToolTip(YearlyDetails11, error); } }