public void AddAlphabetSymbol(string wrap) { ObservableCollection <State> newStates = new ObservableCollection <State>(); foreach (var item2 in _states) { newStates.Add(new State { Name = item2.Name }); } AlphabetSymbols.Clear(); AlphabetSymbols.Add(new AlphabetCell { Name = " ", States = newStates }); var temp = wrap.ToArray <char>().Distinct(); foreach (var item in temp) { if (!AlphabetSymbols.Select(x => x.Name).Contains(item.ToString()) && item != " ".ToCharArray()[0]) { var newCell = new AlphabetCell { Name = item.ToString() }; var statesss = new ObservableCollection <State>(); foreach (var state in _states) { statesss.Add(new State { Name = state.Name }); } newCell.States = statesss; AlphabetSymbols.Add(newCell); } } }
public void AddAlphabetSymbol2(string wrap) { ObservableCollection <State> statesHeaders = new ObservableCollection <State>(); foreach (var stateHeader in _states) { statesHeaders.Add(stateHeader.Clone() as State); } ObservableCollection <AlphabetCell> oldCells = new ObservableCollection <AlphabetCell>(); foreach (var oldSymbol in AlphabetSymbols) { oldCells.Add(oldSymbol.Clone() as AlphabetCell); } AlphabetSymbols.Clear(); AlphabetSymbols.Add(new AlphabetCell { Name = " ", States = statesHeaders }); var temp = wrap.ToArray <char>().Distinct(); foreach (var item in temp) { if (!AlphabetSymbols.Select(x => x.Name).Contains(item.ToString()) && item != " ".ToCharArray()[0]) { var newCell = new AlphabetCell { Name = item.ToString() }; newCell.States = statesHeaders; AlphabetSymbols.Add(newCell); } } }