treeview

WPF TreeView 相关技巧

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-23 22:51:28
WPF 中的 TreeView 相关实用技巧如下 响应 TreeViewItem 的双击事件 这是一个较怪异的问题,如果在 TreeView 的 MouseDoubleClick 中去处理 SelectedItem 时,则在当一个树节点下只有一个子节点时,双击该子节点会转到它的父节点上。 使用方法应当是这样。先在 TreeView 中定义如下资源(注意是 TreeView 的资源) <TreeView.Resources> <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource {x:Type TreeViewItem}}"> <EventSetter Event="MouseDoubleClick" Handler="OnItemMouseDoubleClick"/> </Style> </TreeView.Resources> 然后,在 OnItemMouseDoubleClick 中使用 Sender 作为双击的节点即可。 private void OnItemMouseDoubleClick(object sender, MouseButtonEventArgs e) { TreeViewItem item = (TreeViewItem) sender; //do it... } 自定义节点样式

TreeView中节点勾选设置

佐手、 提交于 2020-01-23 22:50:08
本文转载: http://www.cnblogs.com/luxiaoxun/p/3288003.html 很不错的文章: http://www.cnblogs.com/allen0118/archive/2012/11/28/2793037.html TreeView树中节点勾选要求: 1、不选中一个节点,则其所有的子节点都不被选中。 2、选中一个节点,则其所有的子节点都被选中。 3、当一个节点的所有子节点都没有被选中时,该节点也没有被选中。 4、当一个节点的所有子节点中有一个被选中时,则该节点也被选中。 代码中对事件参数e.Action的判断,可以避免在改变节点的Checked的状态时,再次进入AfterCheck(),这样当在AfterCheck()中有其他逻辑响应时,可以做到每次勾选时,其他逻辑也只响应一次。 参考代码: private void treeView_AfterCheck( object sender, TreeViewEventArgs e) { // 通过鼠标或者键盘触发事件,防止修改节点的Checked状态时候再次进入 if (e.Action == TreeViewAction.ByMouse || e.Action == TreeViewAction.ByKeyboard) { SetChildNodeCheckedState(e.Node, e

while dragging, I don't see helper-lines in Silverlight

回眸只為那壹抹淺笑 提交于 2020-01-23 18:54:05
问题 Silverlight 4, Toolkit During dragging an item on TARGET CONTROL, there are NOT visible lines showing (during mouse move) actual position where will be dragged item put on (for example, between items, inside item, before item, …) source control <toolkit:ListBoxDragDropTarget AllowDrop="False" AllowedSourceEffects="Copy, Link, Scroll"> <ListBox ItemsSource="{Binding ToolboxItems}"> <ListBox.ItemTemplate> <DataTemplate> <!-- some binding --> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <

How to display all files under folders in treeview [closed]

跟風遠走 提交于 2020-01-23 18:39:30
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Iam trying to get all drives, folders, subfolders and files in treeview control using winforms. I have seen the following article. http://codehill.com/2013/06/list-drives-and-folders-in-a-treeview-using-c/ but this only shows drives, folders and sub folders but not the files containing in these folders. Please

How to display all files under folders in treeview [closed]

泪湿孤枕 提交于 2020-01-23 18:38:47
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Iam trying to get all drives, folders, subfolders and files in treeview control using winforms. I have seen the following article. http://codehill.com/2013/06/list-drives-and-folders-in-a-treeview-using-c/ but this only shows drives, folders and sub folders but not the files containing in these folders. Please

Using a TreeNode as a User Setting

瘦欲@ 提交于 2020-01-23 16:21:32
问题 I'm trying to use a TreeNode (System.Windows.Forms.TreeNode) as a user setting for one of my applications. if(treeView.SelectedNode != null) { Properties.Settings.Default.SelectedTreeNode = treeView.SelectedNode; Properties.Settings.Default.Save(); } Then on Application Load I'm trying to use that Setting if (Properties.Settings.Default.SelectedTreeNode != null) treeView.SelectedNode= Properties.Settings.Default.SelectedTreeNode; but no matter what I do, Properties.Settings.Default

Flutter TreeView Json Data Parsing

寵の児 提交于 2020-01-23 04:17:33
问题 I want to use this flutter treeview widget in my flutter app to build companies treeview https://pub.dev/packages/tree_view i have a webservice with list of companies in a tree structure. https://washservice.com/api/companyXML/1fe5bae2-331a-4080-b34f-5ebd3518efd8 I have written json parsing code with recursive function to build treeview but it is not working .can someone help me to fix parsing issue and build treeview widget Here is my code import 'dart:async'; import 'dart:convert'; import

How to highlight entire row in WPF TreeView

三世轮回 提交于 2020-01-23 01:28:07
问题 I want to adapt the default WPF TreeView/TreeViewItem template, so that the entire row can be highlighted, as shown in the image: However, I've tried several templates from googling, but none of them can really make the effects, some wrong answers were even marked as correct... There was an answer in codeflow which seems to work, but it add extra C# code, or didn't need extra code but not working perfectly. I don't want to add extra C# code, but only change the default template. Anyone have

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

TreeView node highlight colour in C#

混江龙づ霸主 提交于 2020-01-22 19:44:52
问题 Using Windows Forms, when I click on a TreeView node, the highlight colour is blue. Is there a way to change this? 回答1: It is possible if you create your own TreeView class and override the OnDrawNode method. For example, this one will highlight selected node with red color: class ClassMyTreeView:TreeView { public ClassMyTreeView() { this.DrawMode = TreeViewDrawMode.OwnerDrawText; } protected override void OnDrawNode(DrawTreeNodeEventArgs e) { TreeNodeStates state = e.State; Font font = e