This question is locked. New answers and comments are not allowed.
Hi,
I have a problem with my Drag Drop Functionality with TileView.
After Loading I am able to Drag and Drop the content from ListBox to TileView.(Actually its swapping).
But when i Drag and Drop from within the TileView and after that again Drag and Drop from List Box i get an Error Stating
System.ArgumentException:Value Doesnot fall within Range.
Below is my code,
And the Code is,
I have a problem with my Drag Drop Functionality with TileView.
After Loading I am able to Drag and Drop the content from ListBox to TileView.(Actually its swapping).
But when i Drag and Drop from within the TileView and after that again Drag and Drop from List Box i get an Error Stating
System.ArgumentException:Value Doesnot fall within Range.
Below is my code,
<UserControl x:Class="Iatric.SAM.DashBoard.Reports" xmlns:telerikControl="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:dragDrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" xmlns:telerikStyle="http://schemas.telerik.com/2008/xaml/presentation" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:telerik1="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d"> <UserControl.Resources> <DataTemplate x:Key="DragCueTemplate"> <Button /> </DataTemplate> <Style TargetType="ListBoxItem" x:Key="draggableItemStyle"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="telerik1:RadDragAndDropManager.AllowDrag" Value="True" /> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White" VerticalAlignment="Top"> <Grid.RowDefinitions> <RowDefinition Height="30" /> <RowDefinition Height="800" /> </Grid.RowDefinitions> <ListBox x:Name="lstReportsContainer" telerik1:RadDragAndDropManager.AllowDrop="True" ItemContainerStyle="{StaticResource draggableItemStyle}" Grid.Row="0"> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush="#FFDADADA" BorderThickness="0,0,1,1" Height="131" CornerRadius="3" Margin="5"> <Border BorderBrush="#B2ADBDD1" BorderThickness="1" CornerRadius="2"> <StackPanel Orientation="Horizontal"> <Button Command="{Binding Tag}" Content="{Binding Content}" /> </StackPanel> </Border> </Border> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <telerikNavigation:RadTileView Name="tileDragDropPanel" Height="Auto" MaximizeMode="Zero" telerik1:RadDragAndDropManager.AllowDrop="True" IsItemDraggingEnabled="True" Grid.Row="2" TileStateChangeTrigger="None"> </telerikNavigation:RadTileView> </Grid></UserControl>Imports System.Collections.ObjectModelImports System.IOImports System.Xml.LinqImports Iatric.SAM.InfrastructureImports System.Windows.MediaImports System.Windows.Media.AnimationImports Iatric.SAM.DashBoard.ControlsImports Telerik.Windows.Controls.DragDropImports Telerik.Windows.ControlsImports Telerik.WindowsPartial Public Class Reports Inherits UserControl Private tileViewItemInfo As RadTileViewItem Dim currentTileView As List(Of String) Private Shared _viewList As New Dictionary(Of [String], Object)() Dim dragpostion As Integer Public Sub New() InitializeComponent() GetListViewItmes() End Sub Private Sub GetListViewItmes() BindData() RadDragAndDropManager.AddDragInfoHandler(lstReportsContainer, AddressOf OnDragInfo) RadDragAndDropManager.AddDragQueryHandler(lstReportsContainer, AddressOf OnDragQuery) RadDragAndDropManager.AddDropInfoHandler(tileDragDropPanel, AddressOf OnDropInfo) RadDragAndDropManager.AddDropQueryHandler(tileDragDropPanel, AddressOf OnDropQuery) RadDragAndDropManager.SetAllowDrop(tileDragDropPanel, True) End Sub Private Sub BindData() Dim MedicalIdentityReports As New ReportsLauncher(ReportLauncherElements.WebPartNames.MedicalIdentityRprt) Dim ActivityReports As New ReportsLauncher(ReportLauncherElements.WebPartNames.SAMReportActivity) Dim ExceptionReports As New ReportsLauncher(ReportLauncherElements.WebPartNames.PatientUserActivityExcpt) Dim DictionaryReports As New ReportsLauncher(ReportLauncherElements.WebPartNames.DictionaryEditActivity) Dim CareTakerReports As New ReportsLauncher(ReportLauncherElements.WebPartNames.Caretaker) Dim DialUpReports As New ReportsLauncher(ReportLauncherElements.WebPartNames.DialUpActivity) Dim incidentItemList As New List(Of UserControlProperties) From { New UserControlProperties With {.UserControlName = "MedicalIdentityRprt", .UserControlCollection = MedicalIdentityReports}, New UserControlProperties With {.UserControlName = "SAMReportActivity", .UserControlCollection = ActivityReports}, New UserControlProperties With {.UserControlName = "DictionaryEditActivity", .UserControlCollection = DictionaryReports}, New UserControlProperties With {.UserControlName = "Caretaker", .UserControlCollection = CareTakerReports}, New UserControlProperties With {.UserControlName = "DialUpActivity", .UserControlCollection = DialUpReports}, New UserControlProperties With {.UserControlName = "PatientUserActivityExcpt", .UserControlCollection = ExceptionReports} } For Each incidentCollection In incidentItemList If (tileDragDropPanel.Items.Count < 4) Then Dim tileViewItem As New RadTileViewItem() With { _ .Content = incidentCollection.UserControlCollection, .Tag = incidentCollection.UserControlName } 'AddHandler tileViewItem.PositionChanged, AddressOf PositionChanged ' MouseLeftButtonDown += New MouseButtonEventHandler(Page_MouseLeftButtonDown) RadDragAndDropManager.SetAllowDrop(tileViewItem, True) Me.tileDragDropPanel.Items.Add(tileViewItem) Else Dim listBoxButton As New Button With {.Content = incidentCollection.UserControlName, .Tag = incidentCollection.UserControlName} lstReportsContainer.Items.Add(listBoxButton) End If Next End Sub Private Sub PositionChanged(ByVal sender As Object, ByVal e As PositionChangedEventArgs) Throw New NotImplementedException End Sub Private Sub OnDropInfo(ByVal sender As Object, ByVal e As DragDropEventArgs) Try Dim destination = e.Options.Destination If e.Options.Status = DragStatus.DropComplete Then If TypeOf destination Is RadTileView OrElse TypeOf destination Is RadTileViewItem Then Dim header As String = String.Empty Dim selectedSection As String = String.Empty If DirectCast(DirectCast(e.Options.Source, System.Windows.Controls.ListBoxItem).Content, System.Windows.Controls.Button).Content IsNot Nothing Then header = DirectCast(DirectCast(e.Options.Source, System.Windows.Controls.ListBoxItem).Content, System.Windows.Controls.Button).Tag selectedSection = DirectCast(DirectCast(e.Options.Source, System.Windows.Controls.ListBoxItem).Content, System.Windows.Controls.Button).Content AddPanel(selectedSection, header, DirectCast(destination, Telerik.Windows.Controls.RadTileViewItem), DirectCast(e.Options.Source, System.Windows.Controls.ListBoxItem)) End If End If End If Catch ex As Exception End Try End Sub Private Sub OnDropQuery(ByVal sender As Object, ByVal e As DragDropQueryEventArgs) Try Dim destination = e.Options.Destination e.QueryResult = True e.Handled = True Catch ex As Exception End Try End Sub Private Sub OnDragInfo(ByVal sender As Object, ByVal e As DragDropEventArgs) Try If e.Options.Status = DragStatus.DragComplete Then End If Catch ex As Exception End Try End Sub Protected Sub OnDragQuery(ByVal sender As Object, ByVal e As DragDropQueryEventArgs) Try If e.Options.Status = DragStatus.DragQuery Then Dim sourceListBoxItem = e.Options.Source Dim DraggedItemName As String = DirectCast(DirectCast(sourceListBoxItem, System.Windows.Controls.ListBoxItem).Content, System.Windows.Controls.Button).Content Dim dragCue As New ContentControl() dragCue.Content = DraggedItemName dragCue.ContentTemplate = TryCast(Me.Resources("DragCueTemplate"), DataTemplate) e.Options.DragCue = dragCue End If e.QueryResult = True e.Handled = True Catch ex As Exception End Try End Sub Private Sub AddPanel(ByVal selectedSection As String, ByVal header As String, ByVal RemovedTileViewItem As RadTileViewItem, ByVal RemovedListBoxItem As System.Windows.Controls.ListBoxItem) Try Dim TileIndex As Integer = Me.tileDragDropPanel.Items.IndexOf(RemovedTileViewItem) Dim AddedtileViewItem = GetTileViewItem(selectedSection) RadDragAndDropManager.SetAllowDrop(AddedtileViewItem, True) Me.tileDragDropPanel.Items.RemoveAt(TileIndex) Me.tileDragDropPanel.Items.Insert(TileIndex, AddedtileViewItem) Dim ListIndex As Integer = Me.lstReportsContainer.Items.IndexOf(RemovedListBoxItem.Content) Dim listBoxButton As New Button With {.Content = RemovedTileViewItem.Tag, .Tag = RemovedTileViewItem.Tag} Me.lstReportsContainer.Items.RemoveAt(ListIndex) Me.lstReportsContainer.Items.Insert(ListIndex, listBoxButton) Catch ex As Exception End Try End Sub Private Function GetTileViewItem(ByVal selectedSection As String) As RadTileViewItem Select Case selectedSection Case "MedicalIdentityRprt" Dim AddedtileViewItem As New RadTileViewItem() With { _ .Tag = selectedSection, _ .Content = New ReportsLauncher(ReportLauncherElements.WebPartNames.MedicalIdentityRprt) } Return AddedtileViewItem Exit Function Case "SAMReportActivity" Dim AddedtileViewItem As New RadTileViewItem() With { _ .Tag = selectedSection, _ .Content = New ReportsLauncher(ReportLauncherElements.WebPartNames.SAMReportActivity) } Return AddedtileViewItem Exit Function Case "DictionaryEditActivity" Dim AddedtileViewItem As New RadTileViewItem() With { _ .Tag = selectedSection, _ .Content = New ReportsLauncher(ReportLauncherElements.WebPartNames.DictionaryEditActivity) } Return AddedtileViewItem Exit Function Case "PatientUserActivityExcpt" Dim AddedtileViewItem As New RadTileViewItem() With { _ .Tag = selectedSection, _ .Content = New ReportsLauncher(ReportLauncherElements.WebPartNames.PatientUserActivityExcpt) } Return AddedtileViewItem Exit Function Case "Caretaker" Dim AddedtileViewItem As New RadTileViewItem() With { _ .Tag = selectedSection, _ .Content = New ReportsLauncher(ReportLauncherElements.WebPartNames.Caretaker) } Return AddedtileViewItem Exit Function Case "DialUpActivity" Dim AddedtileViewItem As New RadTileViewItem() With { _ .Tag = selectedSection, _ .Content = New ReportsLauncher(ReportLauncherElements.WebPartNames.DialUpActivity) } Return AddedtileViewItem Exit Function End Select End Function End Class