private void MappingType_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (((ComboBox)sender).SelectedItem == null) { return; } var item = (GamepadMappingItem)((FrameworkElement)sender).DataContext; var newItemType = (GamepadMappingItemType)((ComboBox)sender).SelectedItem; item.Type = newItemType; ListViewMappingItems.First(viewItem => viewItem.Content == item).ContentTemplate = DataTemplateForMappingType(newItemType); }
private void RemoveMappingItemClicked(object sender, RoutedEventArgs e) { var item = (GamepadMappingItem)((FrameworkElement)sender).DataContext; ListViewMappingItems.Remove(ListViewMappingItems.First(viewItem => viewItem.Content == item)); }