hierarchicaldatatemplate

using HierarchicalDataTemplate with different nested types

久未见 提交于 2021-02-08 05:22:25
问题 There seems to be a ton of information on HierarchicalDataTemplate, but I have had a hard time finding info specific enough to help me out with hierarchies containing different types. Assuming the following class structure: public class classA { public string name{get;set;} } public class classB { public string name{get;set;} public List<classA> subItems{get;set;} } public class classC { public string name{get;set;} public List<classB> subItems{get;set;} } Now taking into assumption the

Creating menuitems from list with bindings results in blank items

南楼画角 提交于 2021-01-29 20:58:54
问题 I have a Menuitem which is supposed to show a list of quantities as children which show a list of the units defined for this quantity as children. The list of quantities is set in code-behind to the ItemsSource of the MenuItem. <MenuItem Header="common.unitsystem" Name="mnuItemUnits"> <MenuItem.Resources> <DataTemplate DataType="{x:Type guidev:Measurement}"> <StackPanel> <TextBlock Text="Measurement"/> <TextBlock Text="{Binding Name}"/> </StackPanel> </DataTemplate> <HierarchicalDataTemplate

WPF Tooltip Binding

拟墨画扇 提交于 2020-06-25 09:23:17
问题 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 displayed. How do I do that? I understand simple binding and this maybe simple binding too but I can't wrap my head around it. Below is my XAML for the label. Could someone explain to me how I can accomplish this. <HierarchicalDataTemplate> <ListBox

TreeView with MasterDetails and ToggleButton

本秂侑毒 提交于 2020-03-05 06:49:27
问题 I want to create a TreeView with MasterDetails on selected Item. The problem is, that no children are displayed in my SelectedItem, even when the parent is expanded. Somehow the HierarchicalDataTemplate seems to get lost. Maybe I am just wrong with the HierarchicalDataTemplate in the <TreeView.ItemTemplate> . Should I start with ItemsPanelTemplate or something similar? Have no clue at the moment. Here is my XAML: <Window x:Class="TreeViewMasterDetails.MainWindow" xmlns="http://schemas

Change TreeViewItem Template when IsSelected and two types using in TreeView

青春壹個敷衍的年華 提交于 2020-01-23 01:27:04
问题 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

How do I reuse a HierarchicalDataTemplate?

心不动则不痛 提交于 2020-01-13 05:49:32
问题 I have two identical HierarchicalDataTemplates. The only difference is the DataType of the templates. <HierarchicalDataTemplate DataType="{x:Type Data:OuterType}" ItemsSource="{Binding Items}"> <StackPanel>...</StackPanel> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type Data:InnerType}" ItemsSource="{Binding Items}"> <StackPanel>...</StackPanel> </HierarchicalDataTemplate> How can I avoid duplicating the contents of the stack panel in both data templates? I considered

WPF HierarchicalDataTemplate & ItemsControl

徘徊边缘 提交于 2020-01-06 16:54:28
问题 I have a list containing objects that follow this structure. This is not the real classes I am working with, but should explain the concept. CLASSES public class BaseType{} public class TypeA : BaseType{} public class TypeB: BaseType { public List<TypeA> TypeAList { get; private set; } } The List that the ItemsControl binds to is a List<BaseType> XAML <ItemsControl> <ItemsControl.Resources> <HierarchicalDataTemplate DataType="{x:Type local:TypeB}" ItemsSource = "{Binding Path=TypeAList}">

Silverlight vs WPF - Treeview with HierarchialDataTemplate

故事扮演 提交于 2020-01-04 15:17:27
问题 So, the following is easy enough in WPF, but how would you do it in Silverlight? Please note that the trick here is to display both Groups, and Entries on the same level. Additonally you dont know how deep the entries are nested, they might be on the first, or the nth level. This is hard in Silverlight because you lack the DataType="{x:Type local:Group}" property in the H.DataTemplate (or any DataTemplate). Building my own custom DataTempalteSelector also didnt work, because the Hierarchial

WPF: Getting TreeViewItem's constituent controls

拜拜、爱过 提交于 2019-12-25 16:42:28
问题 how can I get the constituent controls making up the TreeViewItem in code if they are inside a hierarichicaldatatemplate? <HierarchicalDataTemplate DataType="{x:Type local:Module}" ItemsSource="{Binding Children}"> <StackPanel Orientation="Horizontal"> <Image Width="16" Height="16" Margin="3,0" Source="Images\module.ico" /> <local:RenamingNode Name="RenamableNode" Text="{Binding Name}" VstaObject="{Binding BindsDirectlyToSource=True}" OnRename="OnRenameOccured" /> </StackPanel> <

How can I specify which TreeViewItem Style/Template for a TreeViewItem Generated from HierarchicalDataTemplate?

我只是一个虾纸丫 提交于 2019-12-25 04:47:17
问题 The Situation: I have two classes that are represented in a TreeView. DiskSpec and DiskSet. DiskSpec can exist by itself, or it can be a child of DiskSet. I am working on enabling DragDrop functionality so that the user can drag a DiskSpec from the DiskSpec node onto a DiskSet to add it to that DiskSet. Now all is working except for one thing. My DragDropHelper class needs to specify in an ItemsPresenter (or related class) that that control is a drag source or a drop target. My TreeView is