Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arbitrary Drag and Drop for WP7

I'm trying to find a method of displaying a text block or that will allow me to arbitrarily drag and drop drop that control around the screen.

I've scoured google and here, but every drag and drop related question I find is around exchanging data, not just position.

Is anyone aware of something ready to go, or can you point me in the direction I should be looking?

like image 877
Lucas Avatar asked Jan 31 '12 08:01

Lucas


1 Answers

You can do this by using behaviors:

<TextBlock Text="Hello!">
    <i:Interaction.Behaviors>
        <el:MouseDragElementBehavior ConstrainToParentBounds="True"/>
    </i:Interaction.Behaviors>
</TextBlock>

You need to add a reference to Microsoft.Expression.Interactions in your solution, and the following namespace at the top of your XAML file:

xmlns:el="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
like image 198
Kevin Gosse Avatar answered Nov 23 '22 08:11

Kevin Gosse