SelectedSlot through a ViewModel problem

6 posts, 0 answers
  1. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 07 May 2014 Link to this post

    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
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 08 May 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 08 May 2014 in reply to Yana Link to this post

    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
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 12 May 2014 Link to this post

    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.
     
  6. Christie Admin
    Christie Admin avatar
    239 posts
    Member since:
    Aug 2013

    Posted 12 May 2014 in reply to Yana Link to this post

    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
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 14 May 2014 Link to this post

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready