chr
2024-02-28 e64d24005284e88daec445c7e79e6b93929d2463
Controls/IconTabItem.cs
@@ -1,46 +1,71 @@
using System.Windows;
using System.Windows.Controls;
namespace WPFProject.Controls
{
    public class IconTabItem : TabItem
    {
        public IconTabItem() : base()
        {
            Visibility = Visibility.Collapsed;
        }
        private string _icon;
        public string Icon
        {
            get => _icon;
            set => _icon = value;
        }
        private bool _isFont;
        public bool IsFont
        {
            get => _isFont;
            set => _isFont = value;
        }
        private Window _Body;
        public Window Body
        {
            get => _Body;
            set => _Body = value;
        }
        // 单Header的字体大小
        public double HeaderFontSize
        {
            get { return (double)GetValue(HeaderFontSizeProperty); }
            set { SetValue(HeaderFontSizeProperty, value); }
        }
        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty HeaderFontSizeProperty =
            DependencyProperty.Register("HeaderFontSize", typeof(double), typeof(IconTabItem), new PropertyMetadata(20.0));
    }
}
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace WPFProject.Controls
{
    public class IconTabItem : TabItem , INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void RaisePropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
        protected void RaiseAndSetIfChanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
        {
            old = @new;
            if (propertyName != null)
            {
                RaisePropertyChanged(propertyName);
            }
        }
        public IconTabItem() : base()
        {
            Visibility = Visibility.Collapsed;
        }
        private bool _isFont;
        public bool IsFont
        {
            get => _isFont;
            set => _isFont = value;
        }
        private Window _Body;
        public Window Body
        {
            get => _Body;
            set => _Body = value;
        }
        private BitmapImage _icon;
        public BitmapImage Icon
        {
            get { return (BitmapImage)GetValue(IconProperty); }
            set { SetValue(IconProperty, value); }
        }
        public static readonly DependencyProperty IconProperty =
            DependencyProperty.Register("Icon", typeof(BitmapImage), typeof(IconTabItem), new PropertyMetadata(
                new BitmapImage(new System.Uri("pack://application:,,,/Resources/Icon/xinzeng_1.png"))));
        // 单Header的字体大小
        public double HeaderFontSize
        {
            get { return (double)GetValue(HeaderFontSizeProperty); }
            set { SetValue(HeaderFontSizeProperty, value); }
        }
        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty HeaderFontSizeProperty =
            DependencyProperty.Register("HeaderFontSize", typeof(double), typeof(IconTabItem), new PropertyMetadata(10.0));
    }
}