wpf怎样动态绑定TabControl的多个TabItem
展开全部
//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<TabItem> _items=new List<TabItem>();
public List<TabItem> Items
{
get { return _items; }
set
{
_items = value;
RaisePropertyChanged(nameof(Items));
}
}
}
//View:
<Window.DataContext>
<local:MainWindowModel/>
</Window.DataContext>
<Grid>
<TabControl ItemsSource="{Binding Items}"/>
</Grid>
效果图
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询