KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i have Listbox with files in, i want to able to right click and open a menu like Delete in order to remove files from the Listbox. currently i have this function after right click on item inside my Listbox private void listBoxFiles_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { } and i implement at XAML Delete menu after right click <ListBox.ContextMenu> <ContextMenu> <MenuItem Header="Delete"/> </ContextMenu> </ListBox.ContextMenu> the function who delete file from my ListBox: private void MenuItemDelete_Click(object sender, RoutedEventArgs e) { if (listBoxFiles.SelectedIndex == -1) { return; } //string filePath = (listBoxFiles.SelectedItem).ToString(); int index = listBoxFiles.SelectedIndex; listBoxFiles.Items.RemoveAt(index); }
Tags (comma-separated)
Save Edits
Cancel