Thursday, May 30, 2013

How to Drag and Drop text boxes to a canvas (C#)


<Canvas x:Name="piccanvas" HorizontalAlignment="Left" Height="460" VerticalAlignment="Top" Width="611" Margin="0,10,0,0">
<Canvas.Background>
<ImageBrush Stretch="Fill" ImageSource="/images/Picture1.jpg"/>
</Canvas.Background>
<StackPanel x:Name="wordspanel" Height="376" Canvas.Left="622" Canvas.Top="2" Width="100">
<TextBox x:Name="txtapple" Height="72" TextWrapping="Wrap" Text="苹果" IsReadOnly="True"/>
<TextBox x:Name="txtbanana" Height="72" TextWrapping="Wrap" Text="香蕉" IsReadOnly="True"/>
<TextBox x:Name="txtorange" Height="72" TextWrapping="Wrap" Text="橙子" IsReadOnly="True"/>
<TextBox x:Name="txtpineapple" Height="72" TextWrapping="Wrap" Text="菠萝" IsReadOnly="True"/>
<TextBox x:Name="txtgrapes" Height="72" TextWrapping="Wrap" Text="葡萄" IsReadOnly="True"/>
</StackPanel>
<Button x:Name="gamepageconfirmbtn" Content="确定" Canvas.Left="602" Canvas.Top="383" Height="82" Width="132"/>
</Canvas>



What i want is to drag the words for example apple to the position(x,y coord) of apple in the image, if it`s not the correct place , then i will go back to the stackpanel


However, i can not find the DragEnter event handler in the text boxes properties, so not sure how to do the drap and drop


I`m programming windows phone os 8.0 native apps(c#), .net framework 4.5


thx in advance


No comments:

Post a Comment