hierarchicaldatatemplate

HierarchicalDataTemplate and HeaderedItemsControl with ControlTemplate fails to show nested data

放肆的年华 提交于 2019-12-04 14:14:56
问题 I can get this pattern to work with Menu and TreeView but I must be missing something when I make an attempt with HeaderedItemsControl : <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Page.Resources> <HierarchicalDataTemplate x:Key="MenuItemTemplate" ItemsSource="{Binding XPath=foo}"> <AccessText Text="{Binding XPath=@a}" /> </HierarchicalDataTemplate> <Style

Setting up WPF treeview triggers to show different images on expand

吃可爱长大的小学妹 提交于 2019-12-04 12:10:45
问题 I have a wpf tree view that displays nodes of various types with corresponding images such as folder images. Initially, the tree and its nodes with corresponding images display as expected. However when a node is expanded, the expectation is that the image for the expanded node should swap to an expanded image. I'm trying to use HierarchicalDataTemplate triggers to set this up. Should the triggers be set up differently? The tree looks something like: (Folder Image) Solutions

Change TreeViewItem Template when IsSelected and two types using in TreeView

痴心易碎 提交于 2019-12-04 09:41:27
In my TreeView I use two differnt classes for binding. For example, I have a Group what can have ChildGroup and can have Items. Example code of this classes: using System.Collections.Generic; using System.Collections.ObjectModel; namespace WpfApplication1 { public class Group { public Group(string name) { Name = name; items = new ObservableCollection<Item>(); groups = new ObservableCollection<Group>(); } public string Name { get; set; } private ObservableCollection<Item> items; private ObservableCollection<Group> groups; public ObservableCollection<Item> Items { get { return items; } } public

Recursive HierarchicalDataTemplate (WPF)

三世轮回 提交于 2019-12-03 16:29:30
I'm not sure how to approach this: I want a TreeView that will display some simple data from a hierarchical data structure. As a basic example (In XML, cause it's easy to type): <Node text="Root"> <Node text="Item 1"> <Node text="Item 1.1" /> </Node> <Node text="Item 2"/> </Node> The catch is that this could theoretically nest infinitely deep, so you can't statically define x number of levels and be done with it. Is there a way to define a HierarchicalDataTemplate that can account for this kind of structure? HeirarchicalDataTemplate is used exactly to solve this kind of issue. You can just use

WPF slow performance - many DataItem=null binding warnings

夙愿已清 提交于 2019-12-03 16:29:16
问题 I have a tree control that exhibits very poor performance and I'm trying to track the source of the problem. I am trying to work out whether warnings such as the following are important: System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=ContextMenu.IsOpen; DataItem=null; target element is 'MultipleSelectionTreeViewItem' (Name=''); target property is 'NoTarget' (type 'Object') The

WPF TreeView hierarchical binding.

若如初见. 提交于 2019-12-03 09:06:47
just starting with wpf. I need to bind the object (Hierarchical) Folder public class Folder { public Folder() { this.Name = string.Empty; this.Modules = new ObservableCollection<Module>(); this.Folders = new List<Folder>(); this.HasChild = false; } public Folder(Folder parent) { this.Name = string.Empty; this.Modules = new ObservableCollection<Module>(); this.Folders = new List<Folder>(); this.HasChild = false; this.Parent = parent; } public bool HasChild { get; set; } public string Name { get; set; } public List<Folder> Folders { get; set; } public ObservableCollection<Module> Modules { get;

Setting up WPF treeview triggers to show different images on expand

▼魔方 西西 提交于 2019-12-03 07:47:47
I have a wpf tree view that displays nodes of various types with corresponding images such as folder images. Initially, the tree and its nodes with corresponding images display as expected. However when a node is expanded, the expectation is that the image for the expanded node should swap to an expanded image. I'm trying to use HierarchicalDataTemplate triggers to set this up. Should the triggers be set up differently? The tree looks something like: (Folder Image) Solutions (SolutionsViewModel) --(Solution Image) Solution 1 (Solution) --(Solution Image) Solution 2 (Solution) (Folder Image)

How to mix databound and static levels in a TreeView?

拟墨画扇 提交于 2019-12-03 07:26:24
问题 I have a collection of Database objects, each containing collections of Schema objects and User objects. I want to bind them to a TreeView, but adding additional static levels in the hierarchy, so that the resulting TreeView looks more or less like this: <TreeView> <TreeViewItem Header="All the databases:"> <TreeViewItem Header="Db1"> <TreeViewItem Header="Here's all the schemas:"> <TreeViewItem Header="Schema1"/> <TreeViewItem Header="Schema2"/> </TreeViewItem> <TreeViewItem Header="Here's

Command Binding in hierarchical datatemplate

柔情痞子 提交于 2019-12-03 03:26:00
I have Menu in my app. I'm visualizing it using hierarchical data template: <MenuItem Header="Main menu" ItemsSource="{Binding ApplicationMenu}" > <MenuItem.ItemTemplate> <HierarchicalDataTemplate DataType="{x:Type tm:RMenuItem}" ItemsSource="{Binding Path=ChildrenItems}"> <MenuItem Header="{Binding Name}" Command="{Binding RunOperationCommand}" /> </HierarchicalDataTemplate> </MenuItem.ItemTemplate> </MenuItem> menu looks like as it should, but Command for each menu item is not fired! Even more - it is not bounded, which could be seen in debugger: get accessor of ICommand Property has been

How to mix databound and static levels in a TreeView?

余生长醉 提交于 2019-12-02 20:56:58
I have a collection of Database objects, each containing collections of Schema objects and User objects. I want to bind them to a TreeView, but adding additional static levels in the hierarchy, so that the resulting TreeView looks more or less like this: <TreeView> <TreeViewItem Header="All the databases:"> <TreeViewItem Header="Db1"> <TreeViewItem Header="Here's all the schemas:"> <TreeViewItem Header="Schema1"/> <TreeViewItem Header="Schema2"/> </TreeViewItem> <TreeViewItem Header="Here's all the users:"> <TreeViewItem Header="User1"/> <TreeViewItem Header="User2"/> </TreeViewItem> <