// Remove and Create User Controls From Main Stack public void CreateRaters() { try { MainStack.Children.RemoveRange(0, MainStack.Children.Count - 1); XMLRateUserContsols webservices = MainXMLHander.ReadXMLFile(); if ((webservices != null) && (webservices.WSRates.Count > 0)) { for (int z = 0; z < webservices.WSRates.Count; z++) { RateUserControl newWSRateMain = new RateUserControl(); RateUserDataControlViewModel model = newWSRateMain.ViewModel.RateDataControl.ViewModel; XMLRateUserControlData i = MainXMLHander.ReadXMLFile().WSRates[z]; newWSRateMain.VerticalAlignment = VerticalAlignment.Stretch; newWSRateMain.HorizontalAlignment = HorizontalAlignment.Stretch; newWSRateMain.Height = Double.NaN; newWSRateMain.Width = Double.NaN; model.RateType = i.Type; model.CurrencyFrom = i.CurrencyFrom; model.CurrencyTo = i.CurrencyTo; model.Symbol = i.Symbol; model.SelectedRefreshTime = model.RefreshTimes.Where(x => x.Key == i.RefreshTime).FirstOrDefault(); model.StartRatingThread(); MainStack.Children.Insert(0, newWSRateMain); WebServices.Add(newWSRateMain, i); } } } catch (Exception e) { MessageBox.Show("Could Not Create Controls : " + e.Message); } }
// Save new Controls to XML. public static void Save(RateUserControl control, XMLRateUserControlData newService) { WebServices[control] = newService; MainXMLHander.SaveServices(WebServices.ToList().Select(x => x.Value).ToList()); }