treeviewitem

Binding SelectedItem in a HierarchicalDataTemplate-applied WPF TreeView

无人久伴 提交于 2019-12-17 18:20:03
问题 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 MyViewModel not TreeViewItem . This is a code snippet from the attached behavior: private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var item = e.NewValue as TreeViewItem; if (item != null) { item

flex tree gets chopped even after using scroll bar

最后都变了- 提交于 2019-12-14 00:40:27
问题 when i use the following tree renderer class the the informtions in the tree gets chopped. Is there any solution to fix this bug. please help me. The PLTree class is as follows: import flash.events.Event; import mx.events.ScrollEvent; import mx.controls.Tree; import mx.core.ScrollPolicy; import mx.core.mx_internal; import mx.events.TreeEvent; public class PLTree extends Tree { private var _lastWidth:Number = 0; private var _lastHeight:Number = 0; public function PLTree() { super();

WPF - Setting different ToggleButton image for each TreeViewItem root node with styles

为君一笑 提交于 2019-12-13 16:04:46
问题 I am new to using styles, resources and templates in WPF. What I need to do is override the ToggleButton +/- in the TreeView to be an image, with a different image for each TreeViewItem root Node. For Instance, I would want an image of a car for the "Car" node, and an image of an airplane for the "Plane" node. I have a colorful and a grayscale image of each (for expanded/collapsed). I've found styles to override the treeview and get the image set for the toggle button, but I am not sure the

Handled RoutedEvent continues to bubble up tree

假装没事ソ 提交于 2019-12-12 11:07:58
问题 I'm developing a TreeView based control and my double click event continues to bubble up my TreeViewItem nodes. The goal is to have the TreeViewItem expand or collapse when it is double clicked. I have a style that applies an event handler for the MouseDoubleClick event to each TreeViewItem . Here's the code that handles the event private void TreeViewItemDoubleClicked( object sender, RoutedEventArgs e ) { // Get the specific tree view item that was double clicked TreeViewItem treeViewItem =

How to get current element on checkbox in WPF

让人想犯罪 __ 提交于 2019-12-12 02:59:04
问题 is there any way to, on "Checked" event fire, get the current "MyClass" element in the code behind given the code below: <TreeView Name="TreeViewName"> <TreeView.Resources > <HierarchicalDataTemplate DataType="{x:Type local:MyClass}" ItemsSource="{Binding Children}"> <StackPanel Orientation="Horizontal"> <CheckBox IsChecked="{Binding Checked}" VerticalAlignment="Center" Checked="OnExplorerCheck" ></CheckBox> <Image Source="{Binding Icon}" Height="15" Margin="5,0,0,0"></Image> <Label Content="

Adding child nodes to a TreeViewItem in numerical order

孤街浪徒 提交于 2019-12-12 02:09:52
问题 I have a program with a TreeView Item that holds child nodes with numerical headers . When adding child nodes to the TreeViewItem I would like to add them numerically, but I don't know how to add nodes in between other ones. I'm guessing I would call to a function that would sort through the child nodes, convert the headers to integers , compare the header with the entered value, and then stop when a node header is greater than the value entered. The new node would have to be entered before

Converting a list into TreeViewItems

こ雲淡風輕ζ 提交于 2019-12-11 22:08:01
问题 I have a list of TransactionTypes and I want each of these to be added as Nodes / TreeViewItems on a TreeView, under another TreeViewItem called 'Audit' . Is there a way to convert each individual item in the list into a new TreeViewItem in a TreeView? And if so, how can it be done most efficiently? Thanks. EDIT: We are using a WPF application and therefore can't use .Nodes / TreeNodes. 回答1: This should work List<TransactionTypes> lstTrans ; TreeViewItem auditNode ; //code that initializes

How to get updated automatically WPF TreeViewItems with values based on .Net class properties?

谁说我不能喝 提交于 2019-12-11 07:30:01
问题 Good morning. I have a class with data derived from InotifyPropertyChange. The data come from a background thread, which searches for files with certain extension in certain locations. Public property of the class reacts to an event OnPropertyChange by updating data in a separate thread. Besides, there are described in XAML TreeView, based on HierarhicalDataTemplates. Each TextBlock inside templates supplied ItemsSource = "{Binding FoundFilePaths, Mode = OneWay, NotifyOnTargetUpdated = True}"

get item from treeView c#

自闭症网瘾萝莉.ら 提交于 2019-12-08 04:20:06
问题 I have a TreeView <TreeView Name="files" Margin="0,0,569,108" Grid.Row="1" ItemsSource="{Binding s1}"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Members}" > <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Name}" /> </StackPanel> <HierarchicalDataTemplate.ItemTemplate> <DataTemplate> <CheckBox Name="CheckBox111" Checked="FileCheckBox_Checked" Unchecked="FileCheckBox_Unchecked"> <ContentPresenter> <ContentPresenter.Content> <StackPanel Orientation=

How do you get the level of a treeviewitem in WPF C#?

戏子无情 提交于 2019-12-07 14:29:42
问题 How do you get the level of a treeviewitem in WPF C#? In windows forms there is a .Level member of the treeview class but there does not seem to be one for WPF C#. 回答1: Build a view model. A View model gves you greater flexibility with the treeview than you can achieve without it. Do yourself a favour, dont walk the visual tree, If a parent node is not visible, it could be virtualised away and your level (or depth) figure will be wrong. build a view model that wraps your data and knows at