开发者

Creating orderable list in WPF using ListBox (HOWTO or better approach?)

开发者 https://www.devze.com 2022-12-25 02:09 出处:网络
I\'ve got a list of things that I want the user to easily edit the order of. Right now I\'m binding them to a ListBox with a custom ItemTemplate. Within that template I have an UP & DOWN button. M

I've got a list of things that I want the user to easily edit the order of. Right now I'm binding them to a ListBox with a custom ItemTemplate. Within that template I have an UP & DOWN button. My goal was to move the item up/down based on the button clicked.

However I'm having trouble associating the button's click event with the actual item in the list. I've seen some folks setup a drag/drop for ordering items but that that would be too complex for this app (it's target user base =1, just me).

I as开发者_运维技巧sume this is possible with a ListBox. Maybe someone has a beter idea on how to implement this? It's not a huge set of data... less than 25 items.


The DataContext of the button (of the entire template, thus inherited by the button) is the item itself. Simply cast it to your desired type.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号