public void LoadGridData() { Action workAction = () => { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (o, args) => { args.Result = from a in _fService.GetAllAirplanes() select new { ID = a.airplaneID, Sæder = a.seats }; }; worker.RunWorkerCompleted += (o, args) => { dgAirplanes.ItemsSource = (IEnumerable)args.Result; }; worker.RunWorkerAsync(); }; dgAirplanes.Dispatcher.BeginInvoke(DispatcherPriority.Background, workAction); }
public static List <ComboBoxItem> AirplaneItems() { return(FService.GetAllAirplanes().Select(a => new ComboBoxItem { Content = a.airplaneID + " seats: " + a.seats, Tag = a.airplaneID, Name = "ComboBoxAirplanes", HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center }).ToList()); }