public Task InitData() { var task=new Task (() => { Thread.Sleep (1000); for (int i=0 ; i<2000 ; i++) { _totalMemberItems.Add (new ListViewMemberItem (string.Format ("孙传芳{0}",i),string.Format ("{0}SCF",i))); _totalMemberItems.Add (new ListViewMemberItem (string.Format ("吴佩浮{0}",i),string.Format ("{0}WPF",i))); _totalMemberItems.Add (new ListViewMemberItem (string.Format ("阎锡山{0}",i),string.Format ("{0}YXS",i))); _totalMemberItems.Add (new ListViewMemberItem (string.Format ("张作霖{0}",i),string.Format ("{0}ZZL",i))); _totalMemberItems.Add (new ListViewMemberItem (string.Format ("袁世凯{0}",i),string.Format ("{0}YSK",i))); _totalMemberItems.Add (new ListViewMemberItem (string.Format ("孙中山{0}",i),string.Format ("{0}SZS",i))); _totalMemberItems.Add (new ListViewMemberItem (string.Format ("蔡锷{0}",i),string.Format ("{0}CE",i))); } Nodes=ParamItem.SelectedMemberNode.Select (item => new SelectedMemberNode (item.Caption)).ToList (); Dispatcher.Invoke (DispatcherPriority.Normal,new Action (() => { foreach (var item in _totalMemberItems) { MemberList.Add (item); } SelectedPopup.Height=Nodes.Count*110+38; var guid=Guid.NewGuid (); for (int i=0 ; i<Nodes.Count ; i++) { var control=new NodeControl (Nodes[i].NodeName,i==0,guid.ToString ()); control.RemoveAuthorEventHandler+=HandlerRemoveAuthorEvent; control.Height=110; NodeControlList.Add (control); ChildrenPanel.Children.Add (control); } })); }); return task; }
public Task InitData() { var task = new Task(() => { var source=new DataSource (); _rootNode=source.Get (source.GetDataFromDB ()); Nodes=ParamItem.SelectedMemberNode.Select (item => new SelectedMemberNode (item.Caption)).ToList (); Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { AuthorsTreeView.ItemsSource=_rootNode; var guid=Guid.NewGuid (); for (int i=0 ; i<Nodes.Count ; i++) { var control=new NodeControl (Nodes[i].NodeName,i==0,guid.ToString ()); control.RemoveAuthorEventHandler+=HandlerRemoveAuthorEvent; control.Height=110; NodeControlList.Add (control); ChildrenPanel.Children.Add (control); } })); }); return task; }