
基本上,下面的方法手动执行所有 *** 作,获取放置位置并检查列表框项目以用作索引引用.
private voID @R_419_6818@BoxDragDropTarget_Drop(object sender,Microsoft.windows.DragEventArgs e){ // only valID for copying if (e.Effects.HasFlag(DragDropEffects.copy)) { SelectionCollection selections = ((ItemDragEventArgs)e.Data.GetData("System.windows.Controls.ItemDragEventArgs")).Data as SelectionCollection; int? index = null; if (selections != null) { Point p1 = e.Getposition(this.LayoutRoot); // get drop position relative to layout root var elements = VisualTreeHelper.FindElementsInHostCoordinates(p1,this.LayoutRoot); // get ui elements at drop location foreach (var dataItem in this.lbxConfiguration.Items) // iteration over data items { // get @R_419_6818@Box item from data item @R_419_6818@BoxItem lbxItem = this.lbxConfiguration.ItemContainerGenerator.ContainerFromItem(dataItem) as @R_419_6818@BoxItem; // find @R_419_6818@Box item that contains drop location if (elements.Contains(lbxItem)) { Point p2 = e.Getposition(lbxItem); // get drop position relative to @R_419_6818@Box item index = this.lbxConfiguration.Items.IndexOf(dataItem); // new item will be inserted immediately before @R_419_6818@Box item if (p2.Y > lbxItem.ActualHeight / 2) index += 1; // new item will be inserted after @R_419_6818@Box item (drop location was in bottom half of @R_419_6818@Box item) break; } } if (index != null) { foreach (var selection in selections) { // adding a new item to the @R_419_6818@Box - adjust this to your model (lbxConfiguration.ItemsSource as I@R_419_6818@<VIEwItem>).Insert((int)index,(selection.Item as VIEwItem).Clone()); } } } }} 总结 以上是内存溢出为你收集整理的获取Silverlight拖放中的drop index全部内容,希望文章能够帮你解决获取Silverlight拖放中的drop index所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)