Exemplo n.º 1
0
        public MainViewModel(IUserService userService,
                             IUserMessageService userMessageService,
                             FriendsViewModel friendsViewModel)
        {
            Title = "Relay Commands Demo";

            userService.UserChanged += (s, e) =>
            {
                CurrentUser = e.NewUser;
            };

            friendsViewModel.Commands.Add(new FriendCommand
            {
                Header  = "Login with this user",
                Command = new RelayCommand <UserData>(user =>
                {
                    userService.SetUser(user);
                })
            });

            GCCommand = new RelayCommand(() =>
            {
                GC.Collect();
                userMessageService.DisplayMessage("Operation Complete", "Ran GC successfully");
            });
        }