mirror of
https://github.com/kwsch/pkNX.git
synced 2026-07-17 08:39:05 -05:00
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace pkNX.WinForms;
|
|
|
|
public class WindowItem : TabItem
|
|
{
|
|
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
|
|
nameof(Title), typeof(string), typeof(WindowItem),
|
|
new PropertyMetadata("Test", OnTitlePropertyChanged));
|
|
|
|
private static void OnTitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
var title = (string)d.GetValue(TitleProperty);
|
|
|
|
if (title == null)
|
|
return;
|
|
|
|
d.SetValue(HeaderProperty, new ClosableHeader(title));
|
|
}
|
|
|
|
public string Title
|
|
{
|
|
get => (string)GetValue(TitleProperty);
|
|
set => SetValue(TitleProperty, value);
|
|
}
|
|
|
|
public WindowItem()
|
|
{
|
|
Header = new ClosableHeader();
|
|
}
|
|
}
|
|
|
|
public partial class DockableWindow : UserControl
|
|
{
|
|
[System.ComponentModel.Bindable(true)]
|
|
public ObservableCollection<WindowItem> Windows { get; set; } = [];
|
|
|
|
protected override void OnInitialized(EventArgs e)
|
|
{
|
|
base.OnInitialized(e);
|
|
|
|
Content = new TabControl
|
|
{
|
|
ItemsSource = Windows,
|
|
};
|
|
}
|
|
}
|