using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 控件Demo { public class Helper { private static Helper instance; public static Helper Instance { get { if (instance == null) instance = new Helper(); return Helper.instance; } } /// <summary> /// 工程列表信息 /// </summary> /// <returns></returns> public List<ProjectConfigModel> GetProjectList() { List<ProjectConfigModel> list = new List<ProjectConfigModel>(); ProjectConfigModel devRoot = new ProjectConfigModel { Name = "开发组A", CreateDate = string.Empty, Version = string.Empty, Child = new List<ProjectConfigModel>(), }; devRoot.Child.Add(new ProjectConfigModel { Name = "孙001", CreateDate = "2014.05.15 11:11:11", Version = "V2.0.0.1" }); devRoot.Child.Add(new ProjectConfigModel { Name = "张111", CreateDate = "2014.05.15 12:11:11", Version = "V2.0.0.2" }); devRoot.Child.Add(new ProjectConfigModel { Name = "周001", CreateDate = "2014.05.15 13:11:11", Version = "V2.0.0.3" }); devRoot.Child.Add(new ProjectConfigModel { Name = "张01", CreateDate = "2014.05.15 14:11:11", Version = "V2.0.0.4" }); devRoot.Child.Add(new ProjectConfigModel { Name = "曹001", CreateDate = "2014.05.15 15:11:11", Version = "V2.0.0.5" }); list.Add(devRoot); ProjectConfigModel testRoot = new ProjectConfigModel { Name = "测试组A", CreateDate = string.Empty, Version = string.Empty, Child = new List<ProjectConfigModel>(), }; testRoot.Child.Add(new ProjectConfigModel { Name = "慕001", CreateDate = "2014.05.15 11:11:11", Version = "V2.0.0.1" }); testRoot.Child.Add(new ProjectConfigModel { Name = "陈001", CreateDate = "2014.05.15 12:11:11", Version = "V2.0.0.2" }); testRoot.Child.Add(new ProjectConfigModel { Name = "张xx", CreateDate = "2014.05.15 13:11:11", Version = "V2.0.0.3" }); testRoot.Child.Add(new ProjectConfigModel { Name = "李xx", CreateDate = "2014.05.15 14:11:11", Version = "V2.0.0.4" }); testRoot.Child.Add(new ProjectConfigModel { Name = "zhoumm", CreateDate = "2014.05.15 15:11:11", Version = "V2.0.0.5" }); list.Add(testRoot); return list; } } } using System; using System.Windows; namespace 控件Demo { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.tlvList.ItemsSource = Helper.Instance.GetProjectList(); } private void MenuItem_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Copy"); } private void Button_Click(object sender, EventArgs e) { Form1 f = new Form1(); f.Show(); } private void button1_Click(object sender, RoutedEventArgs e) { Window1 w = new Window1(); w.Show(); } } } using System.Windows; namespace 控件Demo { /// <summary> /// Window1.xaml 的交互逻辑 /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); this.tv.ItemsSource = Helper.Instance.GetProjectList(); } } }
,