c# - Enable Parent window menus on child button login event in WPF MVVM -
i have scenario, having mainwindow.xaml. window has menus (which disabled) , user controls. on 1 of user control have login button clicking login pop window open up. after successful login want enable main window disabled menu items. how can achieve functionality in wpf mvvm?
are using kind of mvvm framework?
if so.
most of them have kind o event service. example caliburn.micro has eventaggregator.
i call such event in child view model , subscribe in parent one. in scenario (in caliburn.micro):
class childviewmodel { ... public void handlelogin() { ... _eventaggregator.publish(new logineventargs); } } class parentviewmodel : ihandle<logineventargs> { public void handle(logineventargs args) { .. } } with use of such event service achieve separation of viewmodels , flexibility because can handle such loginevents in other view models in application.
as mentioned before many mvvm frameworks has such service:
if not.
you can assembly own event aggregator.
here sources can helpful in such homebrew implementation:
Comments
Post a Comment