示例#1
0
        protected void AddLie(object sender, EventArgs ea)
        {
            InputWindow inputDialog = new InputWindow("New Lie", "An answer, but a false one.", "", mainWindow);

            if (inputDialog.ShowDialog() == true)
            {
                Lie lie = new Lie(inputDialog.Answer);
                lie.Creator = mainWindow.LoggedInStudent;
                challange.Lies.Add(lie);
                mainWindow.app.Data.SaveChanges();

                // refresh (TODO this is a hack, should not be needed)
                mainWindow.Navigate(Challange);
            }
        }
示例#2
0
        protected void EditSelectedLies(object sender, RoutedEventArgs ea)
        {
            foreach (Lie lie in lieList.SelectedItems)
            {
                InputWindow inputDialog = new InputWindow("Editing Lie", "An answer, but a false one.", lie.Text, mainWindow);
                if (inputDialog.ShowDialog() == true)
                {
                    // An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll
                    //Additional information: Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
                    //lieList.Items.Remove(current);
                    //lieList.Items.Add(inputDialog.Answer);
                    lie.Text = inputDialog.Answer;
                }
            }

            mainWindow.app.Data.SaveChanges();

            // refresh (TODO this is a hack, should not be needed)
            mainWindow.Navigate(Challange);
        }