How to do custom double click and delete

8 posts, 1 answers
  1. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 16 Jun 2012 Link to this post

    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


  2. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 18 Jun 2012 Link to this post

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

  3. DevCraft banner
  4. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 18 Jun 2012 Link to this post

    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
  5. Rich
    Rich avatar
    3 posts
    Member since:
    Oct 2013

    Posted 06 Jun 2014 in reply to Vladi Link to this post

    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>


      
  6. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 09 Jun 2014 Link to this post

    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.
     
  7. Rich
    Rich avatar
    3 posts
    Member since:
    Oct 2013

    Posted 11 Jun 2014 in reply to Vladi Link to this post

    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>
  8. Rich
    Rich avatar
    3 posts
    Member since:
    Oct 2013

    Posted 11 Jun 2014 in reply to Rich Link to this post

    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.
  9. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 12 Jun 2014 Link to this post

    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.
     
Back to Top
DevCraft banner