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

How to do custom double click and delete

7 Answers 165 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
HDC
Top achievements
Rank 1
HDC asked on 16 Jun 2012, 06:37 AM
Hi,

When i double click an appointment, i get the dialog for changing the appointment, when i click on the delete button i get a message to delete the appointment. So far so good...

Now i want to handle both events with my own dialogs.

If i double click the appointment, the event "ShowDialog" event is thrown, if i click on the delete button, the "ShowDialog" event is thrown also. But how i do know in this event, if the delete button was clicked or if the user double clicked? It doesn't seem possible to tell the two events appart.

Best Regards,

Peter


7 Answers, 1 is accepted

Sort by
0
Accepted
Vladi
Telerik team
answered on 18 Jun 2012, 11:54 AM
Hi Peter,

You can use the AppointmentEditing and AppointmentDeleting events which are thrown when an appointment is about to be edited/deleted. More information about RadScheduleView events can be found here.

Note that the recommended way to customize the ScheduleView dialogs is to modify their template, the approach is explained in details in this help topic.

All the best,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
HDC
Top achievements
Rank 1
answered on 18 Jun 2012, 04:21 PM
Hi Vladi,

This will work, however, i noticed that the AppointmentDeleting event is fired after the ShowDialog event and the AppointmentEditing event is fired before the ShowDialog Event. So i can set a flag when the Editing event occurs... so that i may know in the ShowDialog event what i need to do. But i still wonder why the events are fired in this way.

But this system is primitive at best, why not render some kind of Action property on the ShowDialog event. It would be much easier to handle that way.

I cannot override the template provided by telerik, because i use a complicated wizard to add an item to the scheduler.

Anyways, i consider this problem as solved, thanks for you help.

Best Regards,

Peter
0
Rich
Top achievements
Rank 1
answered on 06 Jun 2014, 05:42 PM
Hi Vladi: This only seems to work if you do not change the AppointmentStyleSelector.  For Example:  If I add the following to RadScheduleView in the XAML code, the "double click" events go away -- ie: the appointment dialog no longer pops up.. I am sure you can tell me what I need to add to get the Appointment Dialog to pop up in this example :)

<telerik:RadScheduleView x:Name="schedule"  >                            
 
 <telerik:RadScheduleView.ActiveViewDefinition>
  <telerik:TimelineViewDefinition />
 </telerik:RadScheduleView.ActiveViewDefinition>
 
 <telerik:RadScheduleView.AppointmentStyleSelector>
  <telerik:SpecialSlotStyleSelector>
   <telerik:SpecialSlotStyleSelector.DefaultStyle>
    <Style TargetType="telerik:AppointmentItem">
     <Setter Property="Control.Template">
      <Setter.Value>
       <ControlTemplate TargetType="telerik:AppointmentItem">
        <Grid>
         <Rectangle Fill="Blue" />
         <TextBlock HorizontalAlignment="Center" Text="{Binding Appointment.Subject}"
                    TextWrapping="NoWrap" VerticalAlignment="Center" Foreground="Wheat" />
        </Grid>
       </ControlTemplate>
      </Setter.Value>
     </Setter>
    </Style>
   </telerik:SpecialSlotStyleSelector.DefaultStyle>
  </telerik:SpecialSlotStyleSelector>
 </telerik:RadScheduleView.AppointmentStyleSelector>
</telerik:RadScheduleView>


  
0
Vladi
Telerik team
answered on 09 Jun 2014, 07:37 AM
Hi Rich,

When customizing the Style of the AppointmentItems in the control you will need to make sure to customize only the properties that are desired and not override its entire Template. If it is required to customize that Template you need to copy it from the theme you are using and keep its important parts in order to not override it's built-in features. In the described scenario where you are customizing only the Fill (Background) of the appointment item it is not necessary to override the Template of that item. All that you need to do is change the Background property of the AppointmentItem Style. The easiest approach in customizing the built-in Telerik theme of RadScheduleView control is with the use of Implicit Styles. Then next code snippet shows the described approach, note that the AppointmentItemBaseStyle is the default Style taken from the Telerik themes:
<telerik:RadScheduleView ...>
    ...
    <telerik:RadScheduleView.AppointmentStyleSelector>
        <telerik:SpecialSlotStyleSelector>
            <telerik:SpecialSlotStyleSelector.DefaultStyle>
                <Style TargetType="telerik:AppointmentItem" BasedOn="{StaticResource AppointmentItemBaseStyle}">
                    <Setter Property="Background" Value="Blue"/>
                </Style>
            </telerik:SpecialSlotStyleSelector.DefaultStyle>
        </telerik:SpecialSlotStyleSelector>
    </telerik:RadScheduleView.AppointmentStyleSelector>
</telerik:RadScheduleView>

You can also take a look at this online example which demonstrates how to use the AppointmentStyleSelector. Also for more details you can take a look at this help article.

Regards,
Vladi
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.
 
0
Rich
Top achievements
Rank 1
answered on 12 Jun 2014, 02:26 AM
Hi Vladi -- that works great, until I decide I want to change the LOOK of the appointment in greater detail -- ie: gradient fill with the TimeMarker on top of the appointment.  see below......

My code is below, however, I think I understand what you are saying.  If I want to do these things, I need to import the entire TEMPLATE and override the few items I want to change.  

You will notice I am making numerous changes how the Appointment looks in the Appointment Item Template section -- the appointment looks more -- eye candy.  Also, I am changing what TEXT info is displayed on the Appointment.

I was hoping I could do these things without importing the entire TEMPLATE.

Nevertheless, I think you are saying I need to import the entire template, because when I enter  <ControlTemplate TargetType="telerik:AppointmentItem">  I am resetting the entire Control Template for the Appointment Item and need to code in everything for that template..  Is that correct ... did that question make sense?  I know it is kind of confusing...


​
<local:AppointmentStyleSelector x:Key="AppointmentStyleSelector">
   <local:AppointmentStyleSelector.TimelineStyle>
    <Style TargetType="telerik:AppointmentItem">
     <Setter Property="Foreground" Value="Beige" />
     <Setter Property="Margin" Value="0" />
     <Setter Property="IsEnabled" Value="True" />
     <Setter Property="Template">
      <Setter.Value>
       <ControlTemplate TargetType="telerik:AppointmentItem">
        <Grid >
         <Border Background="{Binding Appointment.Category.CategoryBrush, FallbackValue=Transparent}" CornerRadius="5" >
          <Border VerticalAlignment="Top" Background="{Binding Appointment.TimeMarker.TimeMarkerBrush, FallbackValue=Transparent}" Height="5" CornerRadius="5,5,0,0">
          </Border>
         </Border>
         <TextBlock x:Name="txtTextBlock" HorizontalAlignment="Center" TextWrapping="NoWrap" Text="{Binding Appointment.Subject}" />
        </Grid>
       </ControlTemplate>
      </Setter.Value>
     </Setter>
    </Style>
   </local:AppointmentStyleSelector.TimelineStyle>
  </local:AppointmentStyleSelector>
0
Rich
Top achievements
Rank 1
answered on 12 Jun 2014, 02:28 AM
FYI, the problem I am having is the double click and the Popup Menu for the appointment ITEM is not coming up when I entered that code.
0
Vladi
Telerik team
answered on 12 Jun 2014, 10:24 AM
Hello Rich,

Indeed that is what I meant by my previous response.

The default AppointmentItem template contains parts that are required for the double click event to be triggered and the EditAppointmentDialog to be opened. As mentioned when more customizations other than simple properties like the Background of the AppointmentItem are required you will need to import the entire Template of the AppointmentItem and make your customizations without removing major parts in that template.

Regards,
Vladi
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.
 
Tags
ScheduleView
Asked by
HDC
Top achievements
Rank 1
Answers by
Vladi
Telerik team
HDC
Top achievements
Rank 1
Rich
Top achievements
Rank 1
Share this question
or