views:

205

answers:

1

I have a ListBox whose ListBoxItems are generated by a data template. I have a button in the ListBoxItem style that has a button for removing the list item. When the user clicks the button, because it receives focus, the ListBox never has a SelectedIndex. Therefore the Click event on the button is never able to delete the ListBoxItem. Is there someway in which I can delete the list item by finding the parent grid of the list item? The button is a child of the ListBoxItem style grid.

A: 

Hey Robert:

Regarding your problem, I m assuming that each item in the collection which u r binding to list box has a unique id (say).

Then in that case u can bind that unique value to the button of list item. When click is fired u will be getting buttons with unique tags and using this tag value u can remove the list item.

Hope this helps.

Thanks

Ashwani

Ashwani K

related questions