Intersoft ClientUI 8 > ClientUI Fundamentals > Drag-drop Framework Overview > Drag-drop Framework How-to Topics > How-to: Perform Conditional Checking to Determine Whether an Item is Dragable |
The following examples show how to perform conditional checking to determine whether an item is dragable.
DragSourceEvent (EventType = DragInit) and DragInitEvent are the events that raised when the drag is about to start, so it is an ideal event to perform condition that determines whether the item is dragable.
Using Event Handler
XAML |
Copy Code
|
---|---|
<Grid x:Name="LayoutRoot"> <Intersoft:UXListBox x:Name="UXListBox1" HorizontalAlignment="Center" Height="200" VerticalAlignment="Center" Width="150" AllowMoveItem="True" AllowReorderItem="True" DragInit="UXListBox1_DragInit"> <Intersoft:UXListBoxItem Content="Freezed"/> <Intersoft:UXListBoxItem Content="Dragable Item 1"/> <Intersoft:UXListBoxItem Content="Dragable Item 2"/> </Intersoft:UXListBox> </Grid> |
C# |
Copy Code
|
---|---|
private void UXListBox1_DragInit(object sender, Intersoft.Client.UI.Controls.Interactivity.DragEventArgs e) { UXListBoxItem item = e.GetSourceElement() as UXListBoxItem; if (item.Content.ToString() == "Freezed") e.SetCancel(true); } |
Using DragInitEvent
XAML |
Copy Code
|
---|---|
<Grid x:Name="LayoutRoot"> <Intersoft:UXListBox x:Name="UXListBox1" HorizontalAlignment="Center" Height="200" VerticalAlignment="Center" Width="150" AllowMoveItem="True" AllowReorderItem="True"> <Intersoft:UXListBoxItem Content="Freezed"/> <Intersoft:UXListBoxItem Content="Dragable Item 1"/> <Intersoft:UXListBoxItem Content="Dragable Item 2"/> </Intersoft:UXListBox> </Grid> |
C# |
Copy Code
|
---|---|
public MainPage() { // Required to initialize variables InitializeComponent(); ISEventManager.RegisterInstanceHandler( this.UXListBox1, // any element in the routed path which applicable in your scenario ISDragDrop.DragInitEvent, // the routed event new Intersoft.Client.UI.Controls.Interactivity.DragEventHandler(UXListBox1_DragInit), // the event handler true); } private void UXListBox1_DragInit(object sender, Intersoft.Client.UI.Controls.Interactivity.DragEventArgs e) { UXListBoxItem item = e.GetSourceElement() as UXListBoxItem; if (item.Content.ToString() == "Freezed") e.SetCancel(true); } |
Using DragSourceEvent (EventType = DragInit)
XAML |
Copy Code
|
---|---|
<Grid x:Name="LayoutRoot"> <Intersoft:UXListBox x:Name="UXListBox1" HorizontalAlignment="Center" Height="200" VerticalAlignment="Center" Width="150" AllowMoveItem="True" AllowReorderItem="True"> <Intersoft:UXListBoxItem Content="Freezed"/> <Intersoft:UXListBoxItem Content="Dragable Item 1"/> <Intersoft:UXListBoxItem Content="Dragable Item 2"/> </Intersoft:UXListBox> </Grid> |
C# |
Copy Code
|
---|---|
public MainPage() { // Required to initialize variables InitializeComponent(); ISEventManager.RegisterInstanceHandler( this.UXListBox1, // any element in the routed path which applicable in your scenario ISDragDrop.DragSourceEvent, // the routed event new Intersoft.Client.UI.Controls.Interactivity.DragEventHandler(UXListBox1_DragInit), // the event handler true); } private void UXListBox1_DragInit(object sender, Intersoft.Client.UI.Controls.Interactivity.DragEventArgs e) { if (e.GetEventType() == DragEventType.DragInit) { UXListBoxItem item = e.GetSourceElement() as UXListBoxItem; if (item.Content.ToString() == "Freezed") e.SetCancel(true); } } |