wpf怎样动态绑定TabControl的多个TabItem

2024-12-14 18:40:24
推荐回答(1个)
回答1:

//viewModel:
 public class MainWindowModel : NotificationObject
    {
        public MainWindowModel()
        {
            Items.Add(new TabItem(){Header = "123"});
            Items.Add(new TabItem(){Header = "abc"});
            Items.Add(new TabItem(){Header = "a12"});
        }

        private List _items=new List();
        public List Items
        {
            get { return _items; }
            set
            {
                _items = value;
                RaisePropertyChanged(nameof(Items));
            }
        }
    }
 //View:
     
        
    

    
        
    

效果图