Raising UserAddingAppoinment event on Enter Key Press

WPF

Windows Presentation Foundation controls

Raising UserAddingAppoinment event on Enter Key Press

  • rated by 0 users
  • This post has 4 Replies |
  • 1 Follower
  •  Instead of raising UserAddingAppoinment event by double click on the selected Time interval,I need to raise it on the Enter key press...

    Can somebody help me out with samples or any suggestions

     

  • It requires retemplating. Look at the source xaml and find the next DataTemplates for VisualInterval: PART_C1Scheduler_WorkSlot_Template, PART_C1Scheduler_FreeSlot_Template, C1Scheduler_AllDayArea_Template, C1Scheduler_OneMonthDay_Template.

    Make the copy of these templates and place it into Scheduler resources. Then for each template set KeyBinding for Enter key. CommandTargert for each binding should be C1Scheduler.NewAppointmentDialogCommand.

       <Border.InputBindings>
        <KeyBinding Key="Enter" Command="c1sched:C1Scheduler.NewAppointmentDialogCommand" />
       </Border.InputBindings>
     

    Note: if you don't need it right now, wait for V2 release, it would be implemented there.

  •  Thanks for the information. I am fresher moreover new to WPF. It will be helpful if u can help me out with a sample code snippet.

  • Sorry for delay, here is the easiest way:

    <Window x:Class="WpfApplication5.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="500" Width="600" xmlns:c1sched="http://schemas.componentone.com/wpf/C1Schedule">
        <Grid>
            <c1sched:C1Scheduler Name="c1Scheduler1"
                                 KeyDown="c1Scheduler1_KeyDown"
                                 UserAddingAppointment="c1Scheduler1_UserAddingAppointment"/>
        </Grid>
    </Window>

    Code behind:

     public partial class Window1 : Window
     {
      public Window1()
      {
       InitializeComponent();
      }

      private void c1Scheduler1_KeyDown(object sender, KeyEventArgs e)
      {
       if (e.Key == Key.Enter)
       {
        c1Scheduler1.NewAppointmentDialog();
       }
      }

      private void c1Scheduler1_UserAddingAppointment(object sender, C1.WPF.C1Schedule.AppointmentActionEventArgs e)
      {
       // do something
      }
     }

  •  Thanks a lot friend...thats working

Page 1 of 1 (5 items)