c# – 无法从我的Windows Phone 8.1应用程序中的ListView拖动项
发布时间:2020-12-15 22:05:52 所属栏目:百科 来源:网络整理
导读:我正在创建我的第一个 Windows Phone 8.1应用程序作为Windows Store Universal应用程序的一部分.桌面/平板电脑版本已经完成,已在商店中存放了几周,而且效果很好.我小心翼翼地假设尽可能少地构建电话版本,到目前为止我已经取得了合理的成功.但是,有一个问题我
我正在创建我的第一个
Windows Phone 8.1应用程序作为Windows Store Universal应用程序的一部分.桌面/平板电脑版本已经完成,已在商店中存放了几周,而且效果很好.我小心翼翼地假设尽可能少地构建电话版本,到目前为止我已经取得了合理的成功.但是,有一个问题我无法通过实验,Stackoverflow或Google来解决:我无法让ListView中的项目可以拖动.
这是我的应用程序中的一个页面的镜头: 用户通过将练习从右侧的ListView拖动到左侧的区域来创建锻炼程序.他们可以随意拖动练习次数;这就是为什么它不仅仅是一个可以检查项目的列表. 这适用于桌面/平板电脑版本,但在手机版本上,当我点击并按住某个项目时,我无法将其拖动到任何位置.它不会移动,也没有显示任何可以表明它是可拖动的. 这是我用来定义ListView的XAML.它几乎与工作版本完全相同,但我已经打开了一些不存在的属性(我认为是IsSwipeEnabled),希望它们可以实现神奇的工作: <ListView x:Name="StepsList" ItemsSource="{Binding Steps}" ContainerContentChanging="ItemView_ContainerContentChanging" SelectionMode="Single" Drop="StepsList_Drop" Tapped="StepsList_Tapped" CanDragItems="True" AllowDrop="True" ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.Column="1" DragItemsStarting="StepsList_DragItemsStarting" Margin="5,0" IsSwipeEnabled="True" SelectionChanged="StepsList_SelectionChanged"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="MinWidth" Value="300" /> <Setter Property="MaxWidth" Value="300" /> <Setter Property="AllowDrop" Value="True" /> </Style> </ListView.ItemContainerStyle> <ListView.ItemTemplate> <DataTemplate> <local:StepControl Role="StepsSource" Tapped="StepSourceItem_Tapped" /> </DataTemplate> </ListView.ItemTemplate> </ListView> 我在DragItemsStarting事件处理程序代码中放置了一个断点,它永远不会被命中. 解决方法
你需要在后面的代码中设置它.
StepsList.ReorderMode = ListViewReorderMode.Enabled; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |