Select Appointment After Drop

6 posts, 0 answers
  1. Kieron
    Kieron avatar
    8 posts
    Member since:
    Jan 2016

    Posted 02 Aug 2016 Link to this post

    I've got some weird behaviour going on, its probably something I've done, but I can't seem to work out whats going on.

    I've set up two stack panels on my usercontrol, one called New Trip and one called New Misc Job - on initialize of the usercontrol I'm setting up the DragDropManager - actually all I'm doing is specifying the methods for DragIntialize like so :

    DragDropManager.AddDragInitializeHandler(newTripDrag, NewTripDragInitialize);
    DragDropManager.AddDragInitializeHandler(newJobDrag, NewMiscDragInitialize);

     

    When the user drags one of the stackpanels onto the scheduleview, I've got some custom dragdropbehaviour going on, but at the end of the Drop method, it always calls base.Drop() and this is where the weird behaviour comes in, when I'm dragging a trip, it works perfectly and the trip is selected afterwards, but when I drag a misc job, it fires off the SelectedAppointment method with a null value which makes nothing selected afterwards.

    Why would it be calling the SelectedAppointment for one and not the other, is there something I can change to stop this from happening, I've attached the Call Stack from the point of base.Drop() to Setting the SelectedAppointment for when I dragged a Misc Job (if that helps).

  2. Yana
    Admin
    Yana avatar
    4583 posts

    Posted 04 Aug 2016 Link to this post

    Hi Kieron,

    I did not manage to reproduce the described behavior, is it possible to send us some code snippets demonstrating the scenario?

    Thanks in advance.

    Regards,
    Yana
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. Kieron
    Kieron avatar
    19 posts
    Member since:
    Nov 2013

    Posted 19 Apr Link to this post

    I've changed the code quite a bit since I posted this, but still getting issues when I try to select an item after I drop it from outside the grid.  Effectively I've still got the DragDropManager handlers, heres an example :

    private void NewTripDragInitialize(object sender, DragInitializeEventArgs args)
    {
      args.AllowedEffects = DragDropEffects.All;
      var payload = DragDropPayloadManager.GeneratePayload(null);
      ScheduleItem newTrip = new ScheduleItem(true, true, this.mainScheduleView.CurrentDate);
      payload.SetData("DraggedData", newTrip);
      args.Data = payload;
      args.DragVisual = new ContentControl { Content = newTrip, ContentTemplate = LayoutRoot.Resources["DraggedTripTemplate"] as DataTemplate };
      args.DragVisualOffset = new Point(args.RelativeStartPoint.X + 20, args.RelativeStartPoint.Y + 10);
    }

     

    This is then converted on my ScheduleViewDragDropBehaviour class and it runs through my overridden Drop code (which is quite long winded to post on here).  Effectively, the Drop code goes off to our database to create the underlying data and creates the appointment, commits it, selects it and returns.

    scheduleView.CreateNew(item);
    scheduleView.Commit();
    scheduleView.SelectedAppointment = item;

     

    This does actually select the appointment, but the IsSelected property of the AppointmentItem does not appear to get set as my xml which controls a highlighting effect on the appointment does not appear to work until I actually click on the appointment :

    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsSelected" Value="False" />
        </MultiTrigger.Conditions>
        <Setter TargetName="tripSelector" Property="Effect" Value="{x:Null}" />
        <Setter TargetName="tripHolder" Property="Effect" Value="{x:Null}" />
      </MultiTrigger>
    </ControlTemplate.Triggers>
     
  4. Stefan X1
    Admin
    Stefan X1 avatar
    665 posts

    Posted 24 Apr Link to this post

    Hi Kieron,

    Thanks for the provided code.

    I may be missing something, but the provided MultiTrigger would not be working for a selected Appointment, as the IsSelected Condition is set to False. Can you please clarify this?

    Also, would it be possible for you to share some details on to which ControlTemplate the aforementioned MultiTrigger is applied?

    Regards,
    Stefan X1
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Kieron
    Kieron avatar
    19 posts
    Member since:
    Nov 2013

    Posted 24 Apr in reply to Stefan X1 Link to this post

    Hi Stefan,

    The full xml for the AppointmentItem (which the ControlTemplate relates to) is as follows:

    <ControlTemplate x:Key="TripHorizontalControlTemplate" TargetType="scheduleView:AppointmentItem">
        <Grid x:Name="Root">
            <!--NOTE: Add a tooltip-->
            <ToolTipService.ToolTip>
                <ToolTip Style="{StaticResource TripToolTipStyle}"/>
            </ToolTipService.ToolTip>
     
            <Rectangle x:Name="tripSelector" Width="8" Height="8" Fill="Black" HorizontalAlignment="Center">
                <Rectangle.Effect>
                    <DropShadowEffect ShadowDepth="0" Color="Red" Opacity="0.8" BlurRadius="13"/>
                </Rectangle.Effect>
                <Rectangle.LayoutTransform>
                    <RotateTransform Angle="45"/>
                </Rectangle.LayoutTransform>
            </Rectangle>
            <Line x:Name="tripHolder" VerticalAlignment="Stretch" StrokeThickness="3" Stroke="Black" X1="1" Y1="0" X2="1" Y2="{Binding ElementName=Root, Path=ActualHeight}" HorizontalAlignment="Center">
                <Line.Effect>
                    <DropShadowEffect ShadowDepth="0" Color="Red" Opacity="0.8" BlurRadius="13"/>
                </Line.Effect>
            </Line>
        </Grid>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="False" />
                </MultiTrigger.Conditions>
                <Setter TargetName="tripSelector" Property="Effect" Value="{x:Null}" />
                <Setter TargetName="tripHolder" Property="Effect" Value="{x:Null}" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

     

    Effectively the ControlTemplate is just removing effects if the item is not selected (rather than applying the effects if it is selected).

  6. Stefan X1
    Admin
    Stefan X1 avatar
    665 posts

    Posted 26 Apr Link to this post

    Hi Kieron,

    Thank you for the update.

    Unfortunately, based on the provided information I still cannot relate the reported behavior to an issue known to us. In order to avoid any misunderstandings, may I kindly ask you to open a new support thread and demonstrate your setup in a sample application so we can debug and hopefully, provide a solution?

    Additionally, you can take a look at this blog post.

    Thank you in advance for your cooperation.

    Regards,
    Stefan X1
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top