void GenerateUI(SelectedAction selectedAction) { var listBoxes = new List <ListBox>(); foreach (var child in this.gridColumnGroupsContainer.Children) { var listBox = child as ListBox; if (listBox != null) { listBoxes.Add(listBox); } } List <PropertyInformationViewModel> columnZeroItems = null; List <PropertyInformationViewModel> columnOneItems = null; List <PropertyInformationViewModel> columnTwoItems = null; if (listBoxes.Count > 0) { columnZeroItems = listBoxes[0].Items.OfType <PropertyInformationViewModel>().ToList(); } if (listBoxes.Count > 1) { columnOneItems = listBoxes[1].Items.OfType <PropertyInformationViewModel>().ToList(); } if (listBoxes.Count > 2) { columnTwoItems = listBoxes[2].Items.OfType <PropertyInformationViewModel>().ToList(); } if (columnZeroItems == null || columnZeroItems.Count == 0) { MessageBox.Show("You need to add at least one control to the design surface.", "No Data", MessageBoxButton.OK, MessageBoxImage.Error); return; } _viewModel.GenerateUI(selectedAction, columnZeroItems, columnOneItems, columnTwoItems); }
void BtnGenerateUI_OnClick(Object sender, RoutedEventArgs e) { var listBoxes = new List <ListBox>(); foreach (var child in this.gridColumnGroupsContainer.Children) { if (child is ListBox) { listBoxes.Add((ListBox)child); } } List <PropertyInformationViewModel> columnZeroItems = null; List <PropertyInformationViewModel> columnOneItems = null; List <PropertyInformationViewModel> columnTwoItems = null; if (listBoxes.Count > 0) { columnZeroItems = listBoxes[0].Items.OfType <PropertyInformationViewModel>().ToList(); } if (listBoxes.Count > 1) { columnOneItems = listBoxes[1].Items.OfType <PropertyInformationViewModel>().ToList(); } if (listBoxes.Count > 2) { columnTwoItems = listBoxes[2].Items.OfType <PropertyInformationViewModel>().ToList(); } if (columnZeroItems == null || columnZeroItems.Count == 0) { MessageBox.Show("You need to add at least one control to the design surface.", "No Data", MessageBoxButton.OK, MessageBoxImage.Error); return; } _viewModel.GenerateUI(columnZeroItems, columnOneItems, columnTwoItems); }