A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
Thank you for reaching out.
When a WPF window starts closing, WPF first begins cleaning up the UI. This includes the visual items inside the ListView. Because of that, the ListViewItem containers start losing their selected state before the Window_Closing event runs. So when you check ListViewItem.IsSelected inside Window_Closing, it may already be reset to false, even though the user had items selected just before closing.
This is why reading selection from the UI at that moment is not reliable.
To save and restore selection correctly, don’t rely on ListViewItem.IsSelected during Window_Closing. Instead, store the selected state in your data model (your IsSelected property) while the application is still running normally, such as when selection changes or before closing starts. When the app starts again, load those saved IsSelected values back into your data objects, and the ListView will automatically show the same selection through data binding.
Please let us know if you require any further assistance, we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer". So that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.