當前位置: 首頁>>代碼示例>>C#>>正文


C# TreeViewItem.SetBinding方法代碼示例

本文整理匯總了C#中System.Windows.Controls.TreeViewItem.SetBinding方法的典型用法代碼示例。如果您正苦於以下問題:C# TreeViewItem.SetBinding方法的具體用法?C# TreeViewItem.SetBinding怎麽用?C# TreeViewItem.SetBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Controls.TreeViewItem的用法示例。


在下文中一共展示了TreeViewItem.SetBinding方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreatePostEntity

        /// <summary>
        /// 創建或獲取相應崗位科目
        /// </summary>
        /// <param name="virtualPost"></param>
        /// <returns></returns>
        private OrderEntity CreatePostEntity(VirtualPost virtualPost, TreeViewItem treeViewItem, string strFlag)
        {
            ObservableCollection<FBEntity> listFBEntities = new ObservableCollection<FBEntity>();
            OrderEntity oeDepartment = dictDepartment[virtualPost.VirtualDepartment];

            // 已存在的崗位科目
            ObservableCollection<FBEntity> listOfSubjectDepartmentFB = oeDepartment.GetRelationFBEntities(typeof(T_FB_SUBJECTDEPTMENT).Name);

            // 1. 獲取所有已啟用的部門科目
            var itemsDepartmentActived = listOfSubjectDepartmentFB.Where(item =>
            {
                return (item.Entity as T_FB_SUBJECTDEPTMENT).ACTIVED == 1;
            });

            // 2. 遍曆所有已啟用的部門科目, 添加相應的崗位科目,已有科目的,則加上原有的,沒有的,則新增

            foreach (FBEntity entityDepartment in itemsDepartmentActived)
            {
                T_FB_SUBJECTDEPTMENT sd = entityDepartment.Entity as T_FB_SUBJECTDEPTMENT;

                // 是否已有崗位科目的記錄
                List<FBEntity> listPost = entityDepartment.GetRelationFBEntities(typeof(T_FB_SUBJECTPOST).Name, item =>
                {
                    return (item.Entity as T_FB_SUBJECTPOST).OWNERPOSTID == virtualPost.ID;
                });

                // 已有崗位科目,添加。沒有,就新增         
                if (listPost.Count > 0)
                {
                    T_FB_SUBJECTPOST post = listPost[0].Entity as T_FB_SUBJECTPOST;
                    if (post.ACTIVED != sd.ACTIVED)
                    {
                        listPost[0].FBEntityState = FBEntityState.Modified;
                    }
                    //崗位默認處理
                    if (post != null)
                        post = SubjectPostChanged(sd, post, strFlag);
                    listPost[0].Entity = post;
                    listFBEntities.Add(listPost[0]);
                }
                else
                {
                    //臨時添加防止重複數據
                    var a = staticobpost.FirstOrDefault(item => (item.Entity as T_FB_SUBJECTPOST).OWNERPOSTID == virtualPost.ID && (item.Entity as T_FB_SUBJECTPOST).T_FB_SUBJECT != null && (item.Entity as T_FB_SUBJECTPOST).T_FB_SUBJECT.SUBJECTID == sd.T_FB_SUBJECT.SUBJECTID);
                    if (a == null && sd.ACTIVED == 1)
                    {
                        FBEntity fbEntityPostNew = this.CreateSubjectPost(sd, virtualPost, strFlag);
                        listFBEntities.Add(fbEntityPostNew);

                        staticobpost.Add(fbEntityPostNew);
                    }
                    else
                    {
                        listFBEntities.Add(a);
                    }
                }
            }

            FBEntity postFBEntity = virtualPost.ToFBEntity();
            postFBEntity.AddFBEntities<T_FB_SUBJECTPOST>(listFBEntities);
            OrderEntity entityPost = new OrderEntity(postFBEntity);

            Binding binding = new Binding();
            binding.Path = new PropertyPath("Entity.Name");
            treeViewItem.SetBinding(TreeViewItem.HeaderProperty, binding);
            treeViewItem.DataContext = entityPost;
            EntityList.Add(entityPost);
            return entityPost;
        }
開發者ID:JuRogn,項目名稱:OA,代碼行數:74,代碼來源:SubjectDepartment.xaml.cs

示例2: AdditionalNodes_CollectionChanged

        private void AdditionalNodes_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                foreach (IDatabasesTreeViewAdditionalNode additionalNode in e.OldItems)
                {
                    TreeViewItem tvi = ItemContainerGenerator.ContainerFromItem(additionalNode) as TreeViewItem;

                    if (tvi != null)
                        Items.Remove(tvi);
                }
            }

            if (e.NewItems != null)
            {
                foreach (IDatabasesTreeViewAdditionalNode additionalNode in e.NewItems)
                {
                    TreeViewItem tvi = new TreeViewItem();
                    tvi.Header = additionalNode.Name;
                    tvi.ItemTemplate = Application.Current.TryFindResource(additionalNode.DataTemplate) as DataTemplate;

                    Binding binding = new Binding("Items");
                    binding.Source = additionalNode;
                    tvi.SetBinding(TreeViewItem.ItemsSourceProperty, binding);

                    Items.Add(tvi);
                }
            }
        }
開發者ID:hefnerliu,項目名稱:SharpDevelop,代碼行數:29,代碼來源:DatabasesTreeView.xaml.cs

示例3: createTreeViewNodeForToolButton

        private TreeViewItem createTreeViewNodeForToolButton(ToolType toolType, ButtonDisplayInfo dataContext)
        {
            TreeViewItem node = new TreeViewItem()
            {
                Header = dataContext,
                Tag = toolType,
                HeaderTemplate = ToolbarControlNodeDataTemplate,
                ItemContainerStyle = LayoutRoot.Resources["TreeViewItemStyle"] as Style
            };
            // Use item description (if any) for the tooltip
            if (!String.IsNullOrEmpty(dataContext.Description))
            {
                System.Windows.Data.Binding b = new System.Windows.Data.Binding("Description") { Source = dataContext };
                node.SetBinding(ToolTipService.ToolTipProperty, b);
            }

            return node;
        }
開發者ID:konglingjie,項目名稱:arcgis-viewer-silverlight,代碼行數:18,代碼來源:ManageToolbarControl.xaml.cs

示例4: CreateNodeItem

 private TreeViewItem CreateNodeItem(NetworkNode endNode, DataTemplate itemTemplate)
 {
     TreeViewItem nodeRoot = new TreeViewItem();
     Binding nodeBinding = new Binding();
     nodeBinding.Source = endNode;
     nodeBinding.Path = new PropertyPath("Name");
     nodeBinding.Converter = new NodeNameConverter();
     nodeRoot.SetBinding(TreeViewItem.HeaderProperty, nodeBinding);
     nodeRoot.Uid = endNode.Id.ToString(CultureInfo.InvariantCulture);
     nodeRoot.ContextMenu = _nodeMenu;
     nodeRoot.HeaderTemplate = itemTemplate;
     return nodeRoot;
 }
開發者ID:GilbertTeam,項目名稱:Tales-Generator,代碼行數:13,代碼來源:NetworkTree.cs


注:本文中的System.Windows.Controls.TreeViewItem.SetBinding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。