<Window x:Class="DragDropColumns_ListBox.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:my="clr-namespace:DragDropColumns_ListBox"
        Title="MainWindow" Height="700" Width="700">
	<Window.Resources>
		<my:MyViewModel x:Key="MyViewModel"/>
        <Style TargetType="ListBoxItem">
            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
        </Style>
    </Window.Resources>
	<Grid DataContext="{StaticResource MyViewModel}">
		<Grid.RowDefinitions>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
        <telerik:RadGridView Grid.Row="0" 
                             Name="clubsGrid" 
                             ItemsSource="{Binding Clubs}"
                             AllowDrop="True"
                             AutoGenerateColumns="False"
                             Margin="5"
                             my:GridViewDragDropBehavior.IsEnabled="True">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"
                                            Header="Est." 
                                            DataFormatString="{}{0:yyyy}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}" 
                                            Header="Stadium" 
                                            DataFormatString="{}{0:N0}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
        <ListBox Grid.Row="1" 
            Margin="10,20" ItemsSource="{Binding Columns, ElementName=clubsGrid}"
                                            ScrollViewer.VerticalScrollBarVisibility="Auto"
                                            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                            HorizontalAlignment="Stretch"
                 AllowDrop="True"
                                            VerticalAlignment="Center"
                                            BorderThickness="0"
                                            Background="Transparent"
                 my:ListBoxDragDropBehavior.IsEnabled="True"
                                            MinWidth="180" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <CheckBox IsChecked="{Binding IsVisible}"/>
                        <TextBlock Text="{Binding Header}" Foreground="Red" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.Resources>
                <DataTemplate x:Key="DraggedItemTemplate">
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Dragging column:"/>
                            <TextBlock Text="{Binding CurrentDraggedItem.Header}" FontWeight="Bold"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding CurrentDropPosition}" FontWeight="Bold" MinWidth="45"/>
                            <TextBlock Text=", column: (" Foreground="Gray" />
                            <TextBlock Text="{Binding CurrentDraggedOverItem.Header}"/>
                            <TextBlock Text=")" Foreground="Gray" />
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.Resources>
        </ListBox>
	</Grid>
</Window>
