Error when trying to use DragDockPanelHost as Panel of ListView.ItemsPanel

Jul 5, 2012 at 4:42 PM
Edited Jul 5, 2012 at 4:44 PM

Hi all,

I try to apply DragDockPanel to ListView as ItemsPanel but no luck:

<ListView Grid.Column="0" BorderThickness="1"    
                          x:Name="ImageListView"   
                          Margin="1.7,2,0,3"	                       
                          MinWidth="165">  
                   <ListView.ItemsPanel>
                        <ItemsPanelTemplate>
                           <blacklight:DragDockPanelHost>
                                <blacklight:DragDockPanel>

                                </blacklight:DragDockPanel>
                            </blacklight:DragDockPanelHost>
                        </ItemsPanelTemplate>
                    </ListView.ItemsPanel>
            <ListViewItem>aaaa</ListViewItem>
                         <ListViewItem>aaaa</ListViewItem>
            <ListViewItem>aaaa</ListViewItem>
            <ListViewItem>aaaa</ListViewItem>
            <ListViewItem>aaaa</ListViewItem>
        </ListView>


It raise error "VisualTree of ItemsPanelTemplate must contain a Panel. 'Blacklight.Controls.Wpf.DragDockPanelHost' is not a Panel." 
I just want to make my ListView can Drag Drop and Order itself, i tried following this article http://www.codeproject.com/Articles/17266/Drag-and-Drop-Items-in-a-WPF-ListView
but not working as my desire at all.
Please help me.
Thanks

Jul 5, 2012 at 5:16 PM

And if i use DragDockPanelHost.ItemTemplate:

<blacklight:DragDockPanelHost x:Name="dragDockPanelHostWithItemTemplate">
            <blacklight:DragDockPanelHost.ItemTemplate>
                <DataTemplate>
                    <blacklight:DragDockPanel Header="{Binding DisplayName}" Margin="10">
                        <blacklight:DragDockPanel.Content>
                            <TextBlock Foreground="White" Text="{Binding ViewContent}"/>
                        </blacklight:DragDockPanel.Content>
                    </blacklight:DragDockPanel>
                </DataTemplate>
            </blacklight:DragDockPanelHost.ItemTemplate>
        </blacklight:DragDockPanelHost>

i got a weird bug with double Header :


Regards.