This is a migrated thread and some comments may be shown as answers.

How to: reorder items within wrappanel

3 Answers 118 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 28 Nov 2012, 05:09 PM
Hi,

it is posible to use RadListbox to reorder items by drag&drop whihe wrappanel is set as ItemsPanel?

<telerik:RadListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
    <telerik:RadListBox.ItemContainerStyle>
      <Style TargetType="telerik:RadListBoxItem" BasedOn="{StaticResource RadListBoxItemStyle}">
        <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
      </Style>
    </telerik:RadListBox.ItemContainerStyle>
     
    <telerik:RadListBox.DragVisualProvider>
      <telerik:ScreenshotDragVisualProvider />
    </telerik:RadListBox.DragVisualProvider>
     
    <telerik:RadListBox.DragDropBehavior>
      <telerik:ListBoxDragDropBehavior AllowReorder="True"  />
    </telerik:RadListBox.DragDropBehavior>
 
    <telerik:RadListBox.ItemsPanel>
      <ItemsPanelTemplate>
        <WrapPanel />
      </ItemsPanelTemplate>
    </telerik:RadListBox.ItemsPanel>

3 Answers, 1 is accepted

Sort by
0
Accepted
Vladi
Telerik team
answered on 03 Dec 2012, 12:38 PM
Hello Daniel,

To enable the drag and drop reorder of items in RadListBox control when using WrapPanel as ItemsPanel you will need to create a CustomLinearDropVisualProvider that inherits LinearDropVisualProvider and override its GetLocation() method.

I created and attached a sample project for you showing the described approach.

Greetings,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Moe
Top achievements
Rank 1
answered on 19 Dec 2015, 04:41 AM

I know this post is old, but I used the code in the attached project and encounter a bug.

The  LinearDropVisual disappear when scrolling to items beyond the screen (listbox with large items). Or if you scroll to items then drag the visual also disappear.

Any help is appreciated

 

0
Polya
Telerik team
answered on 22 Dec 2015, 12:57 PM
Hello Mohamed Elsheihh,

This behavior of the RadWrapPanel is known to us and is related to the calculation of a container's position inside this panel. Unfortunately we cannot propose a workaround using a RadWrapPanel as it inherits from System.Windows.Controls.Panel.

Instead, I suggest using the VirtualizingWrapPanel instead where the position of a RadListBoxItem is differently calculated, because this panel inherits from System.Windows.Controls.VirtualizingPanel.

Hope this helps.

Regards,
Polya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListBox
Asked by
Daniel
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Moe
Top achievements
Rank 1
Polya
Telerik team
Share this question
or