IScheduleViewDialogHostFactory and ContextMenu

5 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    8 posts
    Member since:
    Mar 2012

    Posted 09 May 2012 Link to this post

    Hi,

    In my app, I can create "appointments" and "quick appointments" : they are exactly the same but only the ScheduleViewDialog will be different.

    So, I've implemented my ScheduleViewDialogHostFactory, and I want to let the user choose with the context menu :

    <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu >
            <telerik:RadMenuItem Header="New appointment..."
                                 CommandTarget="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}"
                                 Command="schedule:RadScheduleViewCommands.CreateAppointment" />
     
            <telerik:RadMenuItem Header="New quick appointment..."
                                 CommandTarget="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}"
                                 Command="schedule:RadScheduleViewCommands.CreateAppointment" />
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>

    How can I find what the user selected between the both on the ScheduleViewDialogHostFactory to display the correct window ?


    I've tried to bind my own commands, and then call the ScheduleViewDialogHostFactory with a parameter like that :

    <telerik:RadMenuItem Header="New quick appointment..."
                             CommandTarget="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}"
                             Command="{Binding QuickAppointmentCreated}"
                             CommandParameter="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}" />

    ScheduleViewModel.cs
    
    public ICommand QuickAppointmentCreated { get; private set; }
    QuickAppointmentCreated = new DelegateCommand(CreateQuickAppointment);
      
    public void CreateQuickAppointment(object param)
    {
    RadScheduleView rsv = param as RadScheduleView;
    IScheduleViewDialogHost cw = ScheduleViewDialogHostFactory.CreateNew(rsv, DialogType.AppointmentDialog,  ModalType.QuickAppointment);
    if (cw != null) { cw.Show(true); }
    }
    ScheduleViewDialogHostFactory.cs
    case ModalType.QuickAppointment:
    {
    CwEditQuickAppointmentDialog cw = new CwEditQuickAppointmentDialog() { ScheduleView = scheduleView
    cw.Closed += new EventHandler<WindowClosedEventArgs>(Dialog_Closed);
    return cw;
    }

    But this scheduleView has no appointment attached...

    Thanks.
  2. Jonathan
    Jonathan avatar
    8 posts
    Member since:
    Mar 2012

    Posted 14 May 2012 Link to this post

    No one ?
  3. DevCraft banner
  4. Jakkie Esschert van den
    Jakkie Esschert van den avatar
    61 posts
    Member since:
    Sep 2009

    Posted 25 Oct 2013 Link to this post

    Did you, or anyone else, ever solve this?

    I'm at the exact same point right now, trying to create different dialog based on the selected menu item (and the type of appointment when opening), but the ScheduleViewDialogHostFactory doesn't seem to support that (in fact it seems to make it impossible).
  5. Jonathan
    Jonathan avatar
    8 posts
    Member since:
    Mar 2012

    Posted 25 Oct 2013 Link to this post

    Hi Jakkie,

    Actually, I did.

    Adapt it to your needs :

    1) ScheduleView :

    <telerik:RadMenuItem
    Header="New appointment..."
    Command="{Binding NormalAppointmentCreated}"
    CommandTarget="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}"
    CommandParameter="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}" />
     
    <telerik:RadMenuItem Header="New quick appointment..."
    Command="{Binding QuickAppointmentCreated}"
    CommandTarget="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}"
    CommandParameter="{Binding Menu.UIElement, RelativeSource={RelativeSource Self}}" />

    2) ScheduleViewModel :

    public enum ModalType
    {
        Normal,
        QuickAppointment,
        ...
    }
     
        public ICommand NormalAppointmentCreated { get; private set; }
        public ICommand QuickAppointmentCreated { get; private set; }
     
        public void NormalAppointment(object param)
        {
            ShowModalDialog(param, DialogType.AppointmentDialog, ModalType.Normal);
        }
     
        public void CreateQuickAppointment(object param)
        {
            ShowModalDialog(param, DialogType.AppointmentDialog, ModalType.QuickAppointment);
        }
     
       private void ShowModalDialog(object param, DialogType dialogType, ModalType modalType)
        {
            if (param != null)
            {
                RadScheduleView rsv = param as RadScheduleView;
                if (rsv != null)
                {
                    IScheduleViewDialogHost cw = ScheduleViewDialogHostFactory.CreateNew(rsv, dialogType, modalType);
                    if (cw != null) { cw.Show(true); }
                }
            }
        }

    3) MyScheduleViewDialogHostFactory :

    public ModalType ModalType { get; set; }
     
    internal IScheduleViewDialogHost CreateNew(RadScheduleView rsv, DialogType dialogType, ModalType modalType)
    {
        this.ModalType = modalType;
        return CreateNew(rsv, DialogType.AppointmentDialog);
    }
     
    public IScheduleViewDialogHost CreateNew(ScheduleViewBase scheduleView, DialogType dialogType)
    {
                    switch (ModalType)
                    {
                        case ModalType.Normal:
                            {
                                CwEditAppointmentDialog cw = new CwEditAppointmentDialog() { ScheduleView = scheduleView };
                                return cw;
                            }
                        case ModalType.QuickAppointment:
                            {
                                CwEditQuickAppointmentDialog cw = new CwEditQuickAppointmentDialog() { ScheduleView = scheduleView };
                                return cw;
                            }
    }
    }

    Hoping this helps you :)
  6. Jakkie Esschert van den
    Jakkie Esschert van den avatar
    61 posts
    Member since:
    Sep 2009

    Posted 25 Oct 2013 Link to this post

    Wow, that was quick :)

    Thanks, I'll take a look on Monday, but it looks good. Thank you.
Back to Top
DevCraft banner