From 3f2397750a3f5bbdf5ef78049c237ebeaff78319 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 3 Dec 2020 03:48:25 +0200 Subject: DataStore fixes. --- .../ViewModels/DataStoreViewVM.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs index 46f388461..16fe59f61 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/DataStoreViewVM.cs @@ -251,6 +251,7 @@ namespace Tango.FSE.MachineConfiguration.ViewModels if (SelectedCollection != null) { _selectedCollectionView = CollectionViewSource.GetDefaultView(SelectedCollection.Items); + _selectedCollectionView.SortDescriptions.Add(new SortDescription(nameof(DataStoreItemModel.Key), ListSortDirection.Ascending)); _selectedCollectionView.Filter = (x) => FilterItems(x as DataStoreItemModel); _selectedCollectionView.Refresh(); } @@ -292,7 +293,20 @@ namespace Tango.FSE.MachineConfiguration.ViewModels return; } + var selectedCollection = SelectedCollection; + var selectedItem = SelectedItem; + await LoadDataStore(); + + if (selectedCollection != null) + { + SelectedCollection = DataStore.Collections.FirstOrDefault(x => x.Name == selectedCollection.Name); + } + + if (SelectedCollection != null && selectedItem != null) + { + SelectedItem = SelectedCollection.Items.FirstOrDefault(x => x.Key == selectedItem.Key); + } } private async Task LoadDataStore() -- cgit v1.3.1