FloatableDialog/POC/WpfApp1/DialogService.cs

32 lines
839 B
C#

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