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

IScheduleViewDialogHostFactory and ContextMenu

4 Answers 79 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 09 May 2012, 05:03 PM
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.

4 Answers, 1 is accepted

Sort by
0
Jonathan
Top achievements
Rank 1
answered on 14 May 2012, 02:11 PM
No one ?
0
Jakkie Esschert van den
Top achievements
Rank 1
answered on 25 Oct 2013, 03:25 PM
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).
0
Jonathan
Top achievements
Rank 1
answered on 25 Oct 2013, 04:05 PM
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 :)
0
Jakkie Esschert van den
Top achievements
Rank 1
answered on 25 Oct 2013, 04:20 PM
Wow, that was quick :)

Thanks, I'll take a look on Monday, but it looks good. Thank you.
Tags
ScheduleView
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Jonathan
Top achievements
Rank 1
Jakkie Esschert van den
Top achievements
Rank 1
Share this question
or