using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
namespace ytLive.Helpers;
///
/// A ListBox that keeps selection and keyboard focus coherent when the
/// selected item is deleted. Focus lands on the item now at the deleted
/// position (the previous item when the last one was removed) or leaves
/// the box entirely when it becomes empty. Drag-to-reorder is untouched.
///
public class FocusPreservingListBox : ListBox
{
///
/// Predicate deciding which items the delete-focus fallback may land on
/// (e.g. skip hidden scenes). Null means every item is eligible.
///
public Func