C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Raising UserAddingAppoinment event on Enter Key Press

rated by 0 users
This post has 4 Replies | 1 Follower

Not Ranked
Posts 6
sundar_raju01 Posted: Thu, May 7 2009 4:54 AM

 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

 

Top 25 Contributor
Posts 577
C1_IrinaP replied on Thu, May 7 2009 11:56 AM

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.

Not Ranked
Posts 6

 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.

Top 25 Contributor
Posts 577
C1_IrinaP replied on Tue, May 12 2009 2:00 PM

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
  }
 }

Not Ranked
Posts 6

 Thanks a lot friend...thats working

Page 1 of 1 (5 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.