I have two listview's, one of which accepts Drag/Drops of files, to list the file names. What I want to do is to have the second listview create a custom object, based on the filename of the item in the first list view.
I have the second list views ItemSource bound to the first, and whenever I drag a file into the first, it will show in the second. As expected.
I am now not sure how to convert the items on the second list to my custom object. I tried applying an converter onto the binding, however the object in the Convert function is of ItemCollection (As that is what is being bound).
So is it possible t开发者_如何学编程o convert these in the bindings? Or just go with dealing with the conversion and everything in the drop event, adding to a seperate collection which the second listview is bound to?
Can't you just set an ItemTemplate on the second ListView? Then you could pretty much display anything you want
Duh! Late night programming = bad programmes
What I should have done, and consequentially have done, is to create an ObservableCollection of my custom class, bound both listviews to this list, and on the drop event create my custom class from the dropped data. As my class's ToString() method returned the filename, I didn't need to worry about an ItemTemplate for the first list, as that will show the filename by default.
The second list did require an ItemTemplate to get the required property, but I was already doing that anyway.
精彩评论