diff --git a/src/BitzArt.Blazor.MVVM/Factory/ViewModelFactory.cs b/src/BitzArt.Blazor.MVVM/Factory/ViewModelFactory.cs index 4ec321b..4383462 100644 --- a/src/BitzArt.Blazor.MVVM/Factory/ViewModelFactory.cs +++ b/src/BitzArt.Blazor.MVVM/Factory/ViewModelFactory.cs @@ -46,6 +46,12 @@ public ViewModel Create(IServiceProvider serviceProvider, Type viewModelType, Co var viewModel = (ViewModel)serviceProvider.GetRequiredKeyedService(typeof(ViewModel), viewModelMap.RegistrationKey); viewModel.Signature = signature; + viewModel.OnComponentStateChanged += (sender) => + { + viewModel.ComponentStateContainer?.NotifyStateChanged(); + return Task.CompletedTask; + }; + foreach (var injection in viewModelMap.Injections) { if (injection.IsServiceInjection) @@ -60,8 +66,10 @@ public ViewModel Create(IServiceProvider serviceProvider, Type viewModelType, Co var injectedViewModel = Create(serviceProvider, injection.DependencyType, nestedSignature, parent: viewModel, affectedViewModels: affectedViewModels); injection.Property.SetValue(viewModel, injectedViewModel); - viewModel.OnComponentStateContainerWasSet += (container) - => injectedViewModel.ComponentStateContainer = container; + viewModel.OnComponentStateContainerWasSet += (container) => + { + injectedViewModel.ComponentStateContainer = container; + }; } else if (injection.IsParentViewModelInjection)