Files
Lattice/Lattice.UI/Controls/LatticeTabStrip.cs

44 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Lattice.Core.Abstractions;
using Microsoft.UI.Xaml.Controls;
namespace Lattice.UI.Controls;
/// <summary>
/// Расширенный TabView для центральной области Lattice.
/// </summary>
public class LatticeTabStrip : TabView
{
private IContextService? _contextService;
public LatticeTabStrip()
{
this.TabCloseRequested += (s, e) =>
{
// Логика удаления вкладки из коллекции
this.TabItems.Remove(e.Tab);
// Если вкладок не осталось, сбрасываем контекст
if (this.TabItems.Count == 0)
{
_contextService?.SetContext("Common");
}
};
}
public void Initialize(IContextService contextService)
{
_contextService = contextService;
this.SelectionChanged += OnSelectionChanged;
}
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.SelectedItem is IDockableComponent component)
{
// Уведомляем ядро о смене контекста для обновления кнопок
_contextService?.SetContext(component.ContextGroup);
}
}
}