public ThermalPlantsDataGrid(EntitiesCollections entitiesCollections) : base(entitiesCollections) { InitializeComponent(); ThermalPlantsCollectionViewModel items = ItemsSource as ThermalPlantsCollectionViewModel; if (items.Count == 1) { ThermalPlantViewModel item = items[0] as ThermalPlantViewModel; if (item.Name == null) { CurrentColumn = NameColumn; NameColumn.IsReadOnly = false; CaseColumn.IsReadOnly = false; } } }
public ThermalPlantsCollectionViewModel GetObjects() { UIObjects = new ThermalPlantsCollectionViewModel(); List <ThermalPlant> dataObjects = ThermalPlantsDataAccess.GetObjects(); foreach (ThermalPlant dataObject in dataObjects) { UIObjects.Add(new ThermalPlantViewModel(dataObject)); } if (UIObjects.Count == 0) { UIObjects.Add(new ThermalPlantViewModel()); } UIObjects.ItemEndEdit += new ItemEndEditEventHandler(ObjectsItemEndEdit); UIObjects.CollectionChanged += new NotifyCollectionChangedEventHandler(ObjectsCollectionChanged); return(UIObjects); }