diff --git a/Seyounth.Hyosung/ViewModels/VarietyViewModel.cs b/Seyounth.Hyosung/ViewModels/VarietyViewModel.cs index 7cd008d..26f0e99 100644 --- a/Seyounth.Hyosung/ViewModels/VarietyViewModel.cs +++ b/Seyounth.Hyosung/ViewModels/VarietyViewModel.cs @@ -20,10 +20,15 @@ public partial class VarietyViewModel : ObservableObject private readonly IVarietyService _varietyService; - public VarietyViewModel(PalletManagerViewModel palletManagerViewModel, IVarietyService varietyService) + private readonly HomeViewModel _homeViewModel; + + public VarietyViewModel(PalletManagerViewModel palletManagerViewModel, IVarietyService varietyService, + HomeViewModel homeViewModel) { Pallets = new ObservableCollection(palletManagerViewModel.Pallets); + _homeViewModel = homeViewModel; + _varietyService = varietyService; _varieties = new ObservableCollection(varietyService.GetAll()); @@ -35,12 +40,12 @@ public partial class VarietyViewModel : ObservableObject }); } - public class SavePalletCompletedMessage + public class SaveVarietyCompletedMessage { } [RelayCommand] - private void OnDeletePallet(object obj) + private void OnDeleteVariety(object obj) { if (obj is Variety variety) { @@ -54,7 +59,7 @@ public partial class VarietyViewModel : ObservableObject } [RelayCommand] - private void OnSavePallet(object obj) + private void OnSaveVariety(object obj) { if (obj is Variety variety) { @@ -66,6 +71,8 @@ public partial class VarietyViewModel : ObservableObject _varietyService.UpdateVarietyAsync(variety); } - WeakReferenceMessenger.Default.Send(new PalletManagerViewModel.SavePalletCompletedMessage()); + //同步更新主页的品种列表 + _homeViewModel.Varieties = Varieties; + WeakReferenceMessenger.Default.Send(new SaveVarietyCompletedMessage()); } } \ No newline at end of file diff --git a/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml b/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml index 9e730a4..0713f96 100644 --- a/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml +++ b/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml @@ -329,13 +329,13 @@