c# - UWP ListView Drag item custom UI -


i'm building uwp app using c# , i'm having problems customize drag ui when i'm doing drag & drop listview.

i'm using dragitemsstarting object set data want drag & drop, event doesn't allow customize ui.

i've added dragstarting it's not being called, don't have chance modify drag ui.

anyone has found problem? idea on how customize drag ui when using listview?

i'm not sure if understand correct , particular case , requirements use default reorder behavior in list view:

<listview x:name="mylistview" itemssource="{binding items}" reordermode="enabled" canreorderitems="true" allowdrop="true"> ... </listview> 

this code allows reorder existed items in listview. adding new items drag&drop need subscribe drop event on listview , add dropped item items collection should of type observablecollection<youritemtype> , assigned/bind listview.itemssource.

if still need customize visual object drag&drop need subscribe on dragstarting event in object , set ui element want:

private async void ondragstarting(uielement sender, dragstartingeventargs args) {     var deferral = args.getdeferral();     args.data.properties.add("itemviewmodel", datacontext);      var rendertargetbitmap = new rendertargetbitmap();     await rendertargetbitmap.renderasync(uielementtodrag);      var buffer = await rendertargetbitmap.getpixelsasync();     var bitmap = softwarebitmap.createcopyfrombuffer(buffer,         bitmappixelformat.bgra8,         rendertargetbitmap.pixelwidth,         rendertargetbitmap.pixelheight,         bitmapalphamode.premultiplied);     args.dragui.setcontentfromsoftwarebitmap(bitmap);     deferral.complete(); } 

uielementtodrag visual dragable element of type uielement.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -