namespace WpfApp1 { using System; using System.Collections.ObjectModel; using System.Windows.Controls; public class DialogService { private static readonly Lazy LazyInstance = new(() => new DialogService()); private readonly ObservableCollection _dialogs = new(); public DialogService() { Dialogs = new ReadOnlyObservableCollection(_dialogs); } public static DialogService Instance => LazyInstance.Value; public ReadOnlyObservableCollection Dialogs { get; } public void Add(UserControl userControl) { _dialogs.Add(userControl); } public void Remove(UserControl userControl) { _dialogs.Remove(userControl); } } }