diff --git a/EasyZoneBuilder.GUI/NewZone.xaml.cs b/EasyZoneBuilder.GUI/NewZone.xaml.cs index 0fe2ea5..afee896 100644 --- a/EasyZoneBuilder.GUI/NewZone.xaml.cs +++ b/EasyZoneBuilder.GUI/NewZone.xaml.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -66,11 +67,19 @@ private async void ReadZoneBtn_Click( object sender, RoutedEventArgs e ) ReadZoneBtn.IsEnabled = false; object oldBtnContext = ReadZoneBtn.Content; ReadZoneBtn.Content = "Reading..."; + await RefreshAssetGrid(); + ReadZoneBtn.Content = oldBtnContext; + ReadZoneBtn.IsEnabled = true; + } + } + + private async Task RefreshAssetGrid() + { + if ( SelectZoneComboBox.SelectedItem is string ss ) + { AssetGrid.ItemsSource = Array.Empty(); cvs.Source = await DependencyGraph.DefaultInstance.GetAssetsAsync(ss); AssetGrid.ItemsSource = cvs.View; - ReadZoneBtn.Content = oldBtnContext; - ReadZoneBtn.IsEnabled = true; } } @@ -104,7 +113,8 @@ private async void SearchBtn_Click( object sender, RoutedEventArgs e ) SearchBtn.IsEnabled = false; object oldContent = SearchBtn.Content; SearchBtn.Content = "Filtering..."; - await cvs.Dispatcher.InvokeAsync(() => cvs.View.Refresh(), System.Windows.Threading.DispatcherPriority.Input); + await RefreshAssetGrid(); + //await cvs.Dispatcher.InvokeAsync(() => cvs.View.Refresh(), System.Windows.Threading.DispatcherPriority.Input); SearchBtn.Content = oldContent; SearchBtn.IsEnabled = true; SearchTextBox.IsEnabled = true;