Some issues

Oct 14, 2009 at 10:52 AM

Hello Kevin,

for first, very thank you for your contribution to Silverlight community with this amazing project. I want use it in my current research project, but I have a couple of issues. Drag Drop Manager (DDM) should be used to allow users drag files to users. File is in XAML represented like this:

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Top">
    <Image Source="{Binding Source={StaticResource this}, Converter={StaticResource fileIconPathConverter}, ConverterParameter='../../_Icons/_FileSystem'}" Width="48" Height="48"/>
    <TextBlock  Text="{Binding NameWithExtension}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>

File is implemented as User Control.

<UserControl x:Class="Spaces.Client.Views.UserControls.File"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="96" Height="96"
    xmlns:converters="clr-namespace:Spaces.Client.Convertes"
    xmlns:dragdrop="clr-namespace:SL_Drag_Drop_BaseClasses;assembly=SL_Drag_Drop_BaseClasses">
    <UserControl.Resources>
        <converters:FileIconPathConverter x:Name="fileIconPathConverter" /> 1
    </UserControl.Resources>
    <Grid>
        <dragdrop:DropTarget ShowHover="False">
            <dragdrop:DropTarget.Content>
                <dragdrop:DragSource AllDropTargetsValid="True"
                                         ShowReturnToOriginalPositionAnimation="False"
                                         DropMode="ReturnDragSource" DragHandleMode="FullDragSource"
                                         Tag="File">
                    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top">
                        <Image Source="{Binding Source={StaticResource this}, Converter={StaticResource fileIconPathConverter}, ConverterParameter='../../_Icons/_FileSystem'}" Width="48" Height="48"/>
                        <TextBlock  Text="{Binding NameWithExtension}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </StackPanel>
                </dragdrop:DragSource>
            </dragdrop:DropTarget.Content>
            <dragdrop:DropTarget.Ghost>
                <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top">
                    <Image Source="{Binding Source={StaticResource this}, Converter={StaticResource fileIconPathConverter}, ConverterParameter='../../_Icons/_FileSystem'}" Width="48" Height="48"/>
                    <TextBlock  Text="{Binding NameWithExtension}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </StackPanel>
            </dragdrop:DropTarget.Ghost>
        </dragdrop:DropTarget>
    </Grid>
</UserControl>

1. Do I need really set a parent container over DropTarget (in this case Grid)? When I don't set any, I get a exception: "DropTarget does not support 1 as content."
Later in code is File user control used like this:
        <ItemsControl Grid.Column="1" Grid.Row="0" ItemsSource="{Binding Source={StaticResource this}}" MouseLeftButtonUp="_itemsControlFiles_MouseLeftButtonUp" Name="_itemsControlFiles" Margin="16,49,14,56">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <userControls:File Width="96" Height="96"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <controlsToolkit:WrapPanel x:Name="_wrapPanelFiles"  Orientation="Horizontal" ItemHeight="96" ItemWidth="96"  Background="Silver"  />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
2. If I start drag container I get a exception: Code: 4004, Category: ManagedRuntimeError, Message: System.NullReferenceException: ContainingLayoutPanel is null. Please make sure that is set.
3. If use your manager, dragable controls have white background color and ovelaps each other? Why?
Best Regards
Anton Kalcik

 

Oct 15, 2009 at 10:41 AM

Nobody have a idea what can I do wrong?

Regards

AKa

Coordinator
Oct 16, 2009 at 10:27 AM

Hello,

 

to answer your questions:

1. Your control should indeed have 1 general parent container.

2. You need to set the ContaingLayoutPanel-variable on your DragDropClasses.  Typically, you'd set this once, at startup of your application, to the containing LayoutRoot.  Have a look at this: http://silverlightdragdrop.codeplex.com/Thread/View.aspx?ThreadId=72180 for details.

3. The default is indeed white, but you can change that by setting the Background-property on the DragSource control.

 

Hope this helps! :)

 

Kind regards,
Kevin. 

Oct 18, 2009 at 10:25 AM

Hi Kevin,

 

thank you very much for helping ! Now works it ;-)....

 

Regards

AKa