Beispiel #1
0
 public void InsertRecord(IRecord record, int index)
 {
     DoOnAsynchThread(() =>
     {
         RecordForm.LoadingViewModel.IsLoading = true;
         try
         {
             //this part may take a while to load/create (e.g. get record types for record type field)
             //so create on asynch thread while loading so doesn't freeze ui
             //then add to observable collection on main thread
             var rowItem = new GridRowViewModel(record, DynamicGridViewModel);
             DoOnMainThread(() =>
             {
                 try
                 {
                     DynamicGridViewModel.GridRecords.Insert(index, rowItem);
                     rowItem.OnLoad();
                     rowItem.RunOnChanges();
                     DynamicGridViewModel.RefreshGridButtons();
                 }
                 finally
                 {
                     RecordForm.LoadingViewModel.IsLoading = false;
                 }
             });
         }
         catch (Exception)
         {
             RecordForm.LoadingViewModel.IsLoading = false;
             throw;
         }
     });
 }