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

Reorder RadListBox

1 Answer 239 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Kathryn
Top achievements
Rank 1
Kathryn asked on 05 Aug 2016, 09:34 PM

I am trying to implement a RadListBox that allows users to reorder the items within itself.  While I have found some old examples of this as well as the sdk examples, I keep getting the following error when I include the ItemContainerStyle reference:

"A style intended for type 'Telerik_Windows_Controls_RadListBox_0_206042439' cannot be applied to type 'ContentPresenter'.

 

In my XAML, I have this:

......

<UserControl.Resources>
        <vm:AgentPreferencesViewModel x:Key="ViewModel" />
        <cnv:CheckBoxConverter x:Key="CheckBoxConverter" />
        <Style TargetType="telerik:RadListBox" x:Key="DraggableItem">
            <Setter Property="telerik:RadDragAndDropManager.AllowDrag" Value="True" />
            <Setter Property="telerik:RadDragAndDropManager.AllowDrop" Value="True" />
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True"/>
        </Style>
    </UserControl.Resources>

......

<telerik:RadListBox ItemContainerStyle="{StaticResource DraggableItem}"
                            ItemsSource="{Binding GridHeaders}"
                            DisplayMemberPath="Name"
                            Grid.Column="0"
                            Grid.Row="0"
                            Margin="20">
                <telerik:RadListBox.DragVisualProvider>
                    <telerik:ScreenshotDragVisualProvider />
                </telerik:RadListBox.DragVisualProvider>
                <telerik:RadListBox.DragDropBehavior>
                    <telerik:ListBoxDragDropBehavior AllowReorder="True" />
                </telerik:RadListBox.DragDropBehavior>
            </telerik:RadListBox>

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 Aug 2016, 07:06 AM
Hi Kathryn,

The Style set to ItemContainerStyle property of RadListBox should have its TargetType set to

RadListBoxItem (not RadListBox). 

I'd suggest you check the Drag and Drop Overview topic in our documentation as well as the ListBox Drag and Drop example at WPF Demos.

Regards,
Yana
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
DragAndDrop
Asked by
Kathryn
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or