Intersoft ClientUI Documentation
How-to: Customize Drag Shadow Object

The following examples show how to customize drag shadow object, when drag drop takes place.

Example

Description

The following example code demonstrates how to create custom object / image and uses it as drag shadow object when drag drop take place.

Code

XAML
Copy Code
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
    <i:Interaction.Behaviors>
        <Intersoft:DragDropBehavior ShadowInit="DragDropBehavior_ShadowInit"/>
    </i:Interaction.Behaviors>
    <Image Source="folder.png" Height="64" Width="64"/>
    <TextBlock Text="My Archive" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
C#
Copy Code
private void DragDropBehavior_ShadowInit(object sender, Intersoft.Client.UI.Controls.Interactivity.DragDropShadowEventArgs e)
{               
    Image originalShadow = e.ShadowObject as Image;

    Image image = new Image() { Source = originalShadow.Source };
    image.Height = originalShadow.ActualHeight;
    image.Width = originalShadow.ActualWidth;

    Border shadow = new Border();
    shadow.BorderThickness = new Thickness(1);
    shadow.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
    shadow.Child = image;
            
    e.ShadowObject = shadow;
}

Example

Description

The following example code demonstrates how to handle ShadowInit event to customize drag shadow object for UXPanel items.

Code

XAML
Copy Code
<Intersoft:UXStackPanel HorizontalAlignment="Center" VerticalAlignment="Center" AllowReorderItem="True" ShadowInit="UXStackPanel_ShadowInit">
        <StackPanel>
                <Image Source="folder.png" Height="64" Width="64"/>
                <TextBlock Text="My Archive" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </StackPanel>
        <StackPanel>
                <Image Source="folder.png" Height="64" Width="64"/>
                <TextBlock Text="My Photos" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </StackPanel>
        <StackPanel>
                <Image Source="folder.png" Height="64" Width="64"/>
                <TextBlock Text="My Videos" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </StackPanel>
</Intersoft:UXStackPanel>
C#
Copy Code
private void UXStackPanel_ShadowInit(object sender, Intersoft.Client.UI.Controls.Interactivity.DragDropShadowEventArgs e)
{
    Image originalShadow = e.ShadowObject as Image;

    Image image = new Image() { Source = originalShadow.Source };
    image.Height = originalShadow.ActualHeight;
    image.Width = originalShadow.ActualWidth;

    Border shadow = new Border();
    shadow.BorderThickness = new Thickness(1);
    shadow.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
    shadow.Child = image;

    e.ShadowObject = shadow;
}

Example

Description

The following example code demonstrates how to handle ShadowInit event to customize drag shadow object for UXListBox Items.

Code

XAML
Copy Code
<Intersoft:UXListBox HorizontalAlignment="Center" VerticalAlignment="Center" AllowReorderItem="True" ItemContentType="ContentAndImage" ShadowInit="UXListBox_ShadowInit">
        <Intersoft:UXListBoxItem Content="My Archive" Icon="folder.png"/>
        <Intersoft:UXListBoxItem Content="My Photos" Icon="folder.png"/>
        <Intersoft:UXListBoxItem Content="My Videos" Icon="folder.png"/>
</Intersoft:UXListBox>
C#
Copy Code
private void UXListBox_ShadowInit(object sender, Intersoft.Client.UI.Controls.Interactivity.DragDropShadowEventArgs e)
{
    Image originalShadow = e.ShadowObject as Image;

    Image image = new Image() { Source = originalShadow.Source };
    image.Height = originalShadow.ActualHeight;
    image.Width = originalShadow.ActualWidth;

    Border shadow = new Border();
    shadow.BorderThickness = new Thickness(1);
    shadow.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
    shadow.Child = image;

    e.ShadowObject = shadow;
}
See Also

Concepts

Other Resources