This is a migrated thread and some comments may be shown as answers.

SelectedSlot through a ViewModel problem

5 Answers 60 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Christie Admin
Top achievements
Rank 1
Christie Admin asked on 07 May 2014, 08:58 PM
Hi,

I have a viewmodel define as the following and I dont know why but the value in the setter of the SelectedSlot property are null verry often:

   public class ViewModel : Telerik.Windows.Controls.ScheduleView.Appointment
    {
        #region Constructors.
        public ViewModel()
        {
            mGroupFilter = new Func<object, bool>(GroupFilterFunc);
        }
        #endregion

        #region Public handlers.
        internal delegate void SlotSelectionChangedHandler(object pSender, ScheduleViewSlotSelectionChangedArgs pArgs);

        internal event SlotSelectionChangedHandler OnSlotSelectionChanged;
        #endregion

        #region Public methods.
        public Func<object, bool> GroupFilter
        {
            get
            {
                return mGroupFilter;
            }
            private set
            {
                if (mGroupFilter != value)
                {
                    mGroupFilter = value;
                    OnPropertyChanged(() => GroupFilter);
                }
            }
        }
        #endregion

        #region Private methods.
        private bool GroupFilterFunc(object pGroupName)
        {
            if (pGroupName is DateTime)
            {
                return ((DateTime)pGroupName).DayOfWeek != DayOfWeek.Saturday && ((DateTime)pGroupName).DayOfWeek != DayOfWeek.Sunday;
            }

            return true;
        }
        #endregion

        #region Public properties.
        public Slot SelectedSlot
        {
            set
            {
                if (mSelectedSlot != value)
                {
                    mSelectedSlot = value;                    
                    this.OnPropertyChanged("SelectedSlot");

                    if (this.OnSlotSelectionChanged != null)
                    {                        
                        ScheduleViewSlotSelectionChangedArgs args = new ScheduleViewSlotSelectionChangedArgs();

                        args.NewSlot = mSelectedSlot;

                        this.OnSlotSelectionChanged(this, args);
                    }
                }
            }
            get
            {                
                return mSelectedSlot;
            }
        }
        #endregion

        #region Private members.
        private Func<object, bool> mGroupFilter;
        private Slot mSelectedSlot;
        #endregion
    }

Thank's
Alain

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 May 2014, 10:08 AM
Hello Alain,

In general SelectedSlot becomes null when you select an appointment - in this case no slot is actually selected. Please check whether this is the case at your side and let us know the result.

I noticed in the provided code that the ViewModel inherits from Appointment, is there any specific reason for that?  I would suggest that you change it to either inherit from Telerik.Windows.Controls.ViewModelBase (our implementation of INotifyPropertyChanged interface) or directly implement the INotifyPropertyChanged interface instead.

Regards,
Yana
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Christie Admin
Top achievements
Rank 1
answered on 08 May 2014, 02:44 PM
Hi Yana,

is this the same scenario when we select a readonly slot???

Regarding the viewmodel, I know but the approach come from a previous suggestion from Telerik for another problem. Do I have to change it???

Thank's
Alain
0
Yana
Telerik team
answered on 12 May 2014, 11:44 AM
Hi Alain,

Special Slots (as read-only slots are actually special slots) are a layer over the slots - they do not provide selection - the slots below them are selected.

As to the ViewModel - indeed, I do not know the exact scenario and how you're using this ViewModel, could you send us more details or the thread where this is discussed?

Regards,
Yana
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Christie Admin
Top achievements
Rank 1
answered on 12 May 2014, 01:30 PM
Hi Yana,

for the viewmodel, in my usercontrol I have 2 properties, "VisibleDays" and "IsWeekendVisible" to determine if the user want to see the weekend or not regarding the "VisibleDays" property.

Regarding the specialslot issue, I need to report through an event on which specialslot the user clicked to do some UI stuff like changing the border color. Do you have something to suggest me or it's totally impossible to achiev this?!?

Thank's
Alain
0
Yana
Telerik team
answered on 14 May 2014, 10:26 AM
Hi Alain,

You will not be able to achieve the exact scenario as by design SpecialSlots do not provide selection,  but you could have similar behavior by making some changes in your current setup.
First, you will need to get the SelectedSlot and according to its Start and End times search inside the SpecialSlots collection and find the corresponding SpecialSlot. This, however, means that you should set the MinorTickLendth property in such a way that both regular and special slots are comparable.

I hope this will help.

Regards,
Yana
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ScheduleView
Asked by
Christie Admin
Top achievements
Rank 1
Answers by
Yana
Telerik team
Christie Admin
Top achievements
Rank 1
Share this question
or