/// <summary>
        /// Creates the view.
        /// </summary>
        /// <param name="scheduler">The scheduler.</param>
        /// <param name="appointment">The appointment.</param>
        /// <returns></returns>
        internal static RecurrenceDialogViewModel CreateView(IScheduler scheduler, IAppointment appointment)
        {
            var         view    = new RecurrenceDialogViewModel(scheduler);
            CultureInfo culture = scheduler.GetCultureInUse();

            DateTime start = appointment.Start;

            RecurrencePattern recurrencePattern = appointment.RecurrenceRule == null
                                                      ? new RecurrencePattern
            {
                Frequency      = RecurrenceFrequency.Weekly,
                Interval       = 1,
                DaysOfWeekMask =
                    appointment.Start.DayOfWeek.GetRecurrenceDay(),
                FirstDayOfWeek = scheduler.GetFirstDayOfWeekInUse(),
            }
                                                      : appointment.RecurrenceRule.Pattern.Copy();

            view.Start          = start;
            view.Duration       = appointment.End - appointment.Start;
            view.MaxOccurrences = recurrencePattern.MaxOccurrences ?? DefaultMaxOccurrences;
            if (recurrencePattern.RecursUntil.HasValue)
            {
                view.RecursUntil = recurrencePattern.RecursUntil.Value;
            }
            view.RecurrenceRangeType = GetRangeType(recurrencePattern);

            view.Interval         = recurrencePattern.Interval;
            view.RecurrenceType   = GetTypeFromRule(recurrencePattern);
            view.DayOfMonth       = recurrencePattern.DayOfMonth ?? culture.Calendar.GetDayOfMonth(start);
            view.NthRecurrenceDay = recurrencePattern.DaysOfWeekMask == RecurrenceDays.None
                                        ? start.DayOfWeek.GetRecurrenceDay()
                                        : recurrencePattern.DaysOfWeekMask;
            view.MonthOfYear = recurrencePattern.MonthOfYear ?? start.Month;
            view.WeekOfMonth = recurrencePattern.DayOrdinal.HasValue
                                   ? FromIntToWeekOfMonth(recurrencePattern.DayOrdinal.Value)
                                   : GetWeekOfMonth(start, view.DayOfMonth);
            view.WeekDays          = CreateWeekDays(scheduler, view.NthRecurrenceDay);
            view.NamesOfMonths     = CalendarHelper.GetNamesOfMonths(culture);
            view.WeekOfMonths      = CreateWeekOfMonths();
            view.nthRecurrenceDays = CreateNthRecurrenceDays(scheduler);

            return(view);
        }
 /// <summary>
 /// Raises the <see cref="RecurrencePattern"/> property changed event.
 /// </summary>
 /// <param name="args">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
 protected virtual void OnRecurrenceRuleChanged(DependencyPropertyChangedEventArgs args)
 {
     this.viewModel = RecurrenceDialogViewModel.CreateView(this.Scheduler, this.Appointment);
 }