✅ Issues with WPF

c#
        public void ListBox_SelectionChanged(object sender, EventArgs e)
        {
            bool unsavedChanges = CheckPersonEdit();
            if (unsavedChanges)
            {
                Debug.WriteLine(unsavedChanges.ToString());
                Person UnsavedPerson = GetPersonFromInputs();
                MessageBox.Show($"{UnsavedPerson} at {PrevSelectedIndex} is unsaved");
            }
            string fullname = (string)(sender as ListBox).SelectedItem;
            if (fullname != null)
            {
                Person person = Persons.First(r => r.Name + " " + r.Surname == fullname);
                PersonClicked(sender, e, person);
                PrevSelectedIndex=Persons.IndexOf(person);
            }
        }

In selection changed it logs True to debug but the messagebox is not shown.
Was this page helpful?