using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;

namespace Khd.Core.Wpf.Form
{
    /// <summary>
    /// UserControl1.xaml 的交互逻辑
    /// </summary>
    public partial class UserControl1 : UserControl
    {
        public static readonly DependencyProperty TabItemInfoProperty = DependencyProperty.Register(
         "TabItemInfo",
         typeof(TabItemInfo),
         typeof(UserControl1),
         new PropertyMetadata(null, OnTabItemInfoChanged));

        public TabItemInfo TabItemInfo
        {
            get { return (TabItemInfo)GetValue(TabItemInfoProperty); }
            set { SetValue(TabItemInfoProperty, value); }
        }

        public UserControl1()
        {
            InitializeComponent();
        }

        private static void OnTabItemInfoChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is UserControl1 userControl)
            {
                // 在这里处理数据变更，例如更新UI
                // userControl.TabItemInfo 包含了最新的数据
                Debug.WriteLine($"ImagePath: {userControl.TabItemInfo?.ImagePath}, Text: {userControl.TabItemInfo?.Text}");
            }
        }

    }
}
