Questions tagged «tabitem»

4
如何将TabControl绑定到ViewModels的集合?
基本上我在MainViewModel.cs中: ObservableCollection<TabItem> MyTabs { get; private set; } 但是,我需要以某种方式不仅可以创建选项卡,还可以在维护MVVM的同时将选项卡的内容加载并链接到其相应的视图模型。 基本上,我如何才能将用户控件作为Tabitem的内容加载,并将该用户控件连接到适当的视图模型。造成这一困难的部分是ViewModel不应构造实际的视图项,对吗?可以吗 基本上,这是否适合MVVM: UserControl address = new AddressControl(); NotificationObject vm = new AddressViewModel(); address.DataContext = vm; MyTabs[0] = new TabItem() { Content = address; } 我只问是因为好了,我是从ViewModel构造一个View(AddressControl),对我来说这听起来像是MVVM。
73 c#  wpf  mvvm  tabcontrol  tabitem 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.