Questions tagged [hierarchicaldatatemplate]

A `HierarchicalDataTemplate` is a subclass of `DataTemplate` that allows you to bind directly to a hierarchy of objects

A HierarchicalDataTemplate is a subclass of DataTemplate that allows you to bind directly to a hierarchy of objects. This provides a powerful means to bind a hierchy of objects to wpf controls that deal with such data, such as TreeViews and Menus.

305 questions
65
votes
4 answers

WPF TreeView HierarchicalDataTemplate - binding to object with multiple child collections

I am trying to get a TreeView to bind my collection so that all groups show nested groups and each group will show entry. How can I use the HierarchicalDataTemplate so that the TreeView will process both SubGroups and Entries collection? Groups show…
longday
  • 4,075
  • 4
  • 28
  • 35
40
votes
1 answer

WPF Treeview Databinding Hierarchal Data with mixed types

I have a bit of a complex situation with WPF Treeview Binding. I have spent the last 2 days trying Google it, and this is the closed I came up with, but it doesn't solve the issue. Here is the situation: I have an object that looks like…
thorkia
  • 1,972
  • 1
  • 20
  • 26
36
votes
12 answers

How to get TreeViewItem from HierarchicalDataTemplate item?

I have a TreeView which uses a HierarchicalDataTemplate to bind its data. It looks like this:
Razzie
  • 30,834
  • 11
  • 63
  • 78
19
votes
2 answers

TreeView, HierarchicalDataTemplate and recursive Data

For my treeview I have two different classes that provide the ItemsSource. public class TreeViewModel : ViewModelBase { public ObservableCollection Items { get; set; } } public class NodeViewModel : ViewModelBase { public…
Mare Infinitus
  • 8,024
  • 8
  • 64
  • 113
16
votes
3 answers

Binding SelectedItem in a HierarchicalDataTemplate-applied WPF TreeView

I have a data-bound TreeView and I want to bind SelectedItem. This attached behavior works perfectly without HierarchicalDataTemplate but with it the attached behavior only works one way (UI to data) not the other because now e.NewValue is…
NS.X.
  • 2,072
  • 5
  • 28
  • 55
14
votes
1 answer

WPF slow performance - many DataItem=null binding warnings

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…
13
votes
4 answers

How to mix databound and static levels in a TreeView?

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…
Pawel Marciniak
  • 2,208
  • 14
  • 17
12
votes
3 answers

WPF Tooltip Binding

I am only two weeks into WPF so this is probably a trivial question. I have a collection "CellList" which has a few properties I would like to bind to a ToolTip so when I hover over a label information from the current instance of CellList is…
Nathan
  • 5,059
  • 16
  • 48
  • 61
10
votes
2 answers

ConverterParameter with Binding on Multibinding

is it possible to add a Binding to a ConverterParameter in a MultiBinding? Something like this:
opiswahn
  • 435
  • 1
  • 5
  • 17
9
votes
2 answers

Why can't a DataTemplate bind to an interface when that DataTemplate was explicitly returned from a DataTemplateSelector?

I've created a DataTemplateSelector which is initialized with a collection of known interfaces. If an item passed into the selector implements one of those interfaces, the associated data template is returned. First, here's the ICategory interface…
9
votes
1 answer

using a CollectionViewSource with HierarchicalDataTemplate

How would you go about using a CollectionViewSource (to supply sorting behavior) in conjunction with a HierarchicalDataTemplate's ItemsSource? So given the code below, how could I apply sorting on the children at each level in the…
pastillman
  • 1,104
  • 2
  • 16
  • 27
9
votes
2 answers

Change context menu in WPF TreeView for data

Is there a way to specify in a TreeView's HierarchicalDataTemplate to use a different ContextMenu depending on a property on the data an item is bound to? For instance, display one ContextMenu if Item.IsFile is true, display a different one if…
Jared
  • 649
  • 2
  • 8
  • 15
8
votes
4 answers

Grouping child objects in WPF TreeView

I am trying to get my tree view to group a collection of similar items by what they are. To keep things generic, my object hierarchy could look like this: Objects Object Group #1 Item #1 (Type 'A') Item #2 (Type 'A') Item #3 (Type…
aalex675
  • 421
  • 1
  • 7
  • 15
8
votes
2 answers

Add a border around all children of a TreeViewItem

I have a TreeView and I am trying to implement a style that will allow me to place a border around all the children of a particular node using the HierarchicalDataTemplate. An example of what I want is shown below: The following code is what I have…
Joseph Devlin
  • 1,754
  • 1
  • 26
  • 37
7
votes
3 answers

Command Binding in hierarchical datatemplate

I have Menu in my app. I'm visualizing it using hierarchical data template:
Andrey Khataev
  • 1,303
  • 6
  • 20
  • 46
1
2 3
20 21