有了ListView,我怎么才能得到列表中的索引,从同一个列表中的项目被删除?(重新排序)我尝试使用以下回调,但DragItemsCompletedEventArgs
或OnDropIntoStagedPhotos
似乎都没有合适的方法。
void TableContentPage::OnStagedDragItemsCompleted(
[[maybe_unused]] ::winrt::Windows::Foundation::IInspectable const &,
[[maybe_unused]] ::winrt::Microsoft::UI::Xaml::Controls::
DragItemsCompletedEventArgs const &args)
{
}
void TableContentPage::OnDropIntoStagedPhotos(
[[maybe_unused]] Windows::Foundation::IInspectable const &sender,
[[maybe_unused]] Microsoft::UI::Xaml::DragEventArgs const &args)
{
}
字符串
我使用以下ListView属性:
<ListView x:Name="ListViewName"
Grid.Row="0"
Grid.Column="0"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.IsHorizontalRailEnabled="True"
CanDragItems="True"
CanReorderItems="True"
IsSwipeEnabled="True"
HorizontalAlignment="Stretch"
AllowDrop="True"
Background="{StaticResource PrimaryColor}"
Drop="OnDropIntoStagedPhotos"
DragOver="OnDragOverStagedPhotos"
DragItemsCompleted="OnStagedDragItemsCompleted"
DragItemsStarting="OnStagedDragItemsStarting"
SelectionMode="Extended"
SelectionChanged="OnStagedPhotosSelectionChanged">
型
1条答案
按热度按时间vngu2lb81#
ListViewBase.DragItemsCompleted给出了被拖动的项目,使用IVector.IndexOf,你可以检索索引。所以,我们只需要区分重新排序和移动。目的地有必要给出区别。
有一个UWP XamlDragAndDrop示例可以参考。
字符串
的数据