❔ WPF ListView with LinkedList
Hello,
I have a ListView/GridView that is binded to a LinkedList. When I use the SelectedItem property of my ListView, it returns the value T of the LinkedListNode that is selected, and not the LinkedListNode itself, which is what I want. How do I get the LinkedListNode?
I could just use the Find() method on my LinkedList with the T value to get the node I want, but I would like to avoid this as it is a linear time operation.
Any help would be greatly appreciated!
7 Replies
I believe this wont work because the enumeration for a
LinkedList<T>
goes over T
and not LinkedListNode<T>
Would making my own linked list class that implements IEnumerable work?
(with the enumerator returning the node instead of the T value)
Do you explicitly need the node?
Well not really, I'm trying to make a song playlist editor. A linked list would be good for adding/removing songs at any position in constant time, and for that i would need the node itself
I see. In that case you can make your own linked list that will enumerate over nodes instead of objects.
Yeah. I'll try to do that. Thanks for your help
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.