在Windows手机中拖放 [英] drag and drop in windows phone

查看:166
本文介绍了在Windows手机中拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施拖放功能来安排列表框的内容。我能够拖动项目。当我尝试将第二个项目拖到第一个项目时,它显示在第一个项目上,但是当我尝试将第一个项目拖动到第二个项目时,第一个项目位于第二个项目之下。我也无法抓住这个滴,所以我可以安排这些项目。

i am trying to implement drag and drop feature to arrange the content of my listbox. I was able to drag the item. when i try to drag the second item to first item, it appears over the first item but when i try to drag the first item to second item, then first item goes under the second item. also i am unable to catch the drop, so that i can arrange the items.

有人可以帮我吗?

这里是我使用的代码示例

here is the sample of code i am using

 <ListBox Name="lstBoxImages" ScrollViewer.VerticalScrollBarVisibility="Disabled">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <toolkits:WrapPanel 
                                Width="450" 
                                Height="Auto" 
                                ItemWidth="225" 
                                ItemHeight="Auto"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>

                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding Source}" Height="200" Width="200" MouseMove="MouseMoving">
                            <i:Interaction.Behaviors>
                            <el:MouseDragElementBehavior ConstrainToParentBounds="False"/>
                        </i:Interaction.Behaviors>

                        </Image>
                    </StackPanel>


                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

代码背后:

protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        List<ImageInfo> lstImages = new List<ImageInfo>();
        lstImages.Add(new ImageInfo() { ImageID = 1, Source = "Images/4.png" });
        lstImages.Add(new ImageInfo() { ImageID = 2, Source = "Images/2.png" });
        lstImages.Add(new ImageInfo() { ImageID = 3, Source = "Images/4.png" });
        lstImages.Add(new ImageInfo() { ImageID = 4, Source = "Images/2.png" });
        lstImages.Add(new ImageInfo() { ImageID = 5, Source = "Images/4.png" });
        lstImages.Add(new ImageInfo() { ImageID = 6, Source = "Images/2.png" });

        lstBoxImages.ItemsSource = lstImages;

    }

    private void MouseMoving(object sender, System.Windows.Input.MouseEventArgs e)
    {
        Image realSender = (Image)sender;
        int zIndex = Canvas.GetZIndex(realSender);
        Canvas.SetZIndex(realSender, zIndex++);
    }

我的信息类是:

public class ImageInfo
{
    private int _ImageID;
    private string _Source;

    public string Source
    {
        get { return _Source; }
        set { _Source = value; }
    }

    public int ImageID
    {
        get { return _ImageID; }
        set { _ImageID = value; }
    }
}

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
xmlns:el="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions"


推荐答案

您可以从 Bewise手机控件工具包中尝试控制可订购列表。 >
另外还有Telerik的 DataBoundListBox RadControls for Windows Phone还支持重新排序项目。

You can try control Orderable List from Bewise phone controls toolkit.
Also DataBoundListBox from Telerik RadControls for Windows Phone also supports items reordering.

这篇关于在Windows手机中拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆