Does this control support drag and drop functionality and if so could you povide me with some sample code?
Hi,
This is what I did:
Item Templete:
<igWindows:XamCarouselListBox.ItemTemplate> <DataTemplate DataType="Imagen"> <Grid Width="150" Height="150" Margin="0,0,0,0" > <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Image Source="{Binding RutaCompleta, Converter={StaticResource imageUriConverter}}" Tag="{Binding IdImagen, Mode=OneWay}" HorizontalAlignment="Left" Width="150" Height="150" VerticalAlignment="Top" MouseLeftButtonDown="DragImage" /> </Grid> </DataTemplate></igWindows:XamCarouselListBox.ItemTemplate>
Code:
private void DragImage(object sender, MouseButtonEventArgs e) { try { Image image = e.Source as Image; if (e.ClickCount == 2) { this.SelectedImage.Source = image.Source; ActualizarTexto(); } else { imagen = GetDataFromListBox(e.GetPosition(ImagenesListBox)) as Imagen; if (imagen != null) { this.ImagenesListBox.SelectedItem = imagen; } DataObject data = new DataObject(typeof(ImageSource), image.Source); DragDrop.DoDragDrop(image, data, DragDropEffects.Copy); } } catch (Exception ex) { MessageBox.Show(ex.ToString());
} } private void DropImage(object sender, DragEventArgs e) { try { ImageSource image = e.Data.GetData(typeof(ImageSource)) as ImageSource; if (image != null) { this.SelectedImage.Source = image; ActualizarTexto(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private object GetDataFromListBox(Point point) { UIElement element = ImagenesListBox.InputHitTest(point) as UIElement; object data = DependencyProperty.UnsetValue; while (data == DependencyProperty.UnsetValue && element != null) { data = ImagenesListBox.ItemContainerGenerator.ItemFromContainer(element); if (data == DependencyProperty.UnsetValue) element = VisualTreeHelper.GetParent(element) as UIElement;
ContentPresenter content = element as ContentPresenter; if (content != null) { data = content.Content; break; } } if (data != DependencyProperty.UnsetValue) return data;
return null; }
I hope this example will help you.
Jaimir G. [MVP]
I had a look however the XamCarouselListBox is completely different then XamDataGrid, XamDataCarousel and XamDataPresenter.
Can you help with specific sample?
You can find a link with a sample in this forum thread : (http://community.infragistics.com/forums/p/36929/213407.aspx#213407)
Can you provide me the code snippets on how you have achieved this funcationality?
I found what the issue was. In the PreviewMouseLeftButtonUp I was setting the Mouse capture to null.
System.Windows.Input.Mouse.Capture(null);