Example #1
0
        private async void addFriendPanel_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var newFriend = new FriendViewModel { Name = "New Friend", Group = "New Friends" };

            var friendSettingsWindow = await showFriendSettingsWindow(newFriend);

            friendSettingsWindow.Closed += (_, __) => ((MainWindowViewModel)DataContext).Friends.Add(newFriend);
        }
Example #2
0
        private async Task<Window> showFriendSettingsWindow(FriendViewModel friend)
        {
            var friendSettingsWindow = new FriendSettingsWindow();
            friendSettingsWindow.Closed += (window, _) => openedWindows.Remove((Window)window);
            openedWindows.Add(friendSettingsWindow);

            friendSettingsWindow.DataContext = friend;
            friendSettingsWindow.Show();

            await Task.Delay(10);

            friendSettingsWindow.Activate();
            friendSettingsWindow.Focus();

            return friendSettingsWindow;
        }