public static string GetCountriesByCode() { var sb = new StringBuilder(); var source = CountriesSource.OrderBy(x => x.Name).ToList(); foreach (var item in source) { sb.AppendLine(string.Format("new Country {3}Code = \"{0}\", PhoneCode = \"{1}\", Name = \"{2}\"{4},", item.PhoneCode.ToLowerInvariant(), item.Code, item.Name, "{", "}")); } return(sb.ToString()); }
public MainWindowViewModel() { Countries = CountriesSource.ToReadOnlyReactiveCollection(); AddCommand.Subscribe(async _ => { await Task.Run(() => { CountriesSource.Add(new CountryViewModel()); }); }); DelCommand.Subscribe(async _ => { await Task.Run(() => { if (CountriesSource.Count > 0) { CountriesSource.RemoveAt(CountriesSource.Count - 1); } }); }); }