We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Controlling Drag of Cards in a Column

Hello,

I am trying to use the Kanban control  in a slightly different way. 

I need to display list a group of objects as cards into two columns. I have that part working.

My data object is a custom IKanBan model object and the datasource is an ObservableCollection.

In my first column, I have two cards (the first one and the very last one) which are special and I don't want to be able to move them, nor can any of the other cards be moved above or below these special cards. 

I was able to block the special cards from from dragging using the CardDragStart event.

I have been trying to cancel the dragging of the other cards above and below the special cards (basically within the same column) using the CardDragEnd event with no success.  If I cancel the DragCardEnd event, the card is still visually moved. Also, this is set up as MVVM so I cannot access the kanban control directly though the code.

Here is my event:

private void CardDragEnd(Syncfusion.UI.Xaml.Kanban.KanbanDragEndEventArgs e)
{
// Auto objects cannot be moved to another column --this part works!!
if (e.TargetColumnIndex != e.SelectedColumnIndex &&
(e.SelectedCard.Content as FileNamingPartKanBanModel).DataObject.IncludePart == PrinterUIInfrastructure.Enums.PNFileNamingPartIncludeWhenEnum.Auto)
{
Debug.WriteLine("CARD DRAG END CANCEL CROSSING COLUMNS");
e.IsCancel = true;
return;
}

// First, last objects must stay first and last  -- this part doesn't cancel the drag!
if ( (e.SelectedColumnIndex == 0 && e.TargetColumnIndex == 0)
  && e.TargetCardIndex == 0)
{
Debug.WriteLine("CARD DRAG END CANCEL SAME COLUMNN");
e.IsCancel = true;
return;
}
}

Thanks,

Sheri


1 Reply

LR Lakshmi Radha Krishnan Syncfusion Team October 1, 2019 06:16 AM

Hi Sheri,

 

Greetings from Syncfusion.

 

Query 1: In my first column, I have two cards (the first one and the very last one) which are special and I don't want to be able to move them

 

You can achieve this requirement using the AllowDrag property in the KanbanColumn. Please refer the below reference link.

 

Link: https://help.syncfusion.com/wpf/sfkanban/column?cs-save-lang=1&cs-lang=xaml#enabledisable-drag--drop

 

Query 2: I have been trying to cancel the dragging of the other cards above and below the special cards

 

You can restrict the card transition from one column to another column using the Category and AllowTransitions property in the Kanban. Please refer the below reference link.

 

Link: https://help.syncfusion.com/wpf/sfkanban/workflows

 

We have prepared a sample for the above queries, please download it form the following location.

 

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Kanban_WPF-377315559

 

Please let us know if you need further assistance on this.

 

Regards,

Lakshmi R. 


Loader.
Live Chat Icon For mobile
Up arrow icon