本文整理汇总了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;
}
示例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);
}
}
}
示例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;
}
示例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;
}