alielie
2025-03-03 21e28b068c8d0763a6d4ab613388a77a0db157fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
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 string _Header;
        public string Header
        {
            get => _Header;
            set => _Header = value;
        }
 
        private Window _Body;
        public Window Body
        {
            get => _Body;
            set => _Body = value;
        }
 
        private ObservableCollection<IconTabItem> _Children;
        public ObservableCollection<IconTabItem> Children
        {
            get => _Children;
            set => RaiseAndSetIfChanged(ref _Children, value);
        }
 
        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));
 
    }
}