Biribu
Biribu

Reputation: 3823

Remove item from listbox in XAML

I have a listbox with items in my xaml page. I introduce those items programmatically (I don't know if this is important). I want to delete them as you do in an app like uwp mail.

I want that whenever you click over the left side, a checkbox appears and a button to send to trash those items. Is this a kind of components or on the contrary I have to code it?

Upvotes: 0

Views: 1099

Answers (1)

Vivek Verma
Vivek Verma

Reputation: 333

If you want to remove the items in a list box, you can do it like this:

listBox1.Items.Clear();

If you want to activate a checkbox in XAML you can add it in the designer, set visible to false. Change it to true in your code behind when you want to activate it and use this to remove a selected item:

listBox1.Items.Remove(item);

You may need to iterate through all the items and check if they are selected.

Upvotes: 1

Related Questions