treeviewitem

Highlight whole TreeViewItem line in WPF

If I set TreeViewItem Background it highlights the header only. How can I highlight the whole line? I have found a post almost solving a problem http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b04f73e2-0b10-4d97-a6da-64df2e30c21d/ But there are some problems: 1. It does not highlight the whole line 2. The tree has XP style on...

Change TreeViewItem Header by trigger

Having such Style <Style TargetType="TreeViewItem"> <Style.Triggers> <Trigger Property="IsExpanded" Value="True"> <Setter Property="Header" Value="Pink"></Setter> </Trigger> </Style.Triggers> </Style> I would expect the text of the expanded TreeViewItems to be "Pink", but nothing set actually. If I change to Propert...

How do you determine the width of the text in a WPF TreeViewItem at run time?

How do you determine the width of the text in a WPF TreeViewItem at run time? I need to calculate an offset so I can draw a line from one leaf to the leaf of a different TreeView. All the 'width' properties return a size that is way bigger than the space taken up by the actual text of the node. It must be possible because the Select f...

Show treeview items connected with lines?

Hi, Is there a way to make the treeview show lines connecting items when we expand them? Thanks! ...

Apply style to all TreeViewItem

Hi The problem am having is that I have multiple TreeView control and each TreeView has its own TreeViewItem styles, setting it TreeView ItemContainerStyle="{StaticResource Style1}" will only set the root element NOT all the child elements, How to apply a style to all the child elements in a TreeView ...

Find Silverlight TreeViewItem control by Header

I am trying to create a TreeView from the Silverlight TreeView control. I have my data being pulled from a WCF service that pulls from EF. All of the data is coming in fine. I have the page set up where I can input a UserName, click a button, and the data will populate the first generation in the TreeView. So, I'm dynamically buildin...

Context Menu for XAML Treeviewitem

In XAML, how do you define a context menu for treeviewitems that are distinguished by different attributes? ...

How can I override TreeViewItem in WPF to allow asynchronous children loading?

I am using MVVM as my WPF architecture and I have a WPF TreeView implemented as delay loading (child items are not loaded recursively until you expand). However, I need to implement asynchronous loading as well upon expansion. Is there a way to do that? I need to keep this in control level and not in code-behind/application level. Than...

C# WPF How do I get a TreeViewItem from HierarchicalDataTemplate item?

I have the same problem as a previous question on this forum: previous thread I have a TreeView which uses a HierarchicalDataTemplate to bind its data. I need to get the TreeViewItem from the selected item, which is my own class. I have tried the solution given in the previous thread as well as modified versions of it. Nothing works....

How to change the color/opacity of the triangular icon on a TreeViewItem?

Some of my TreeViewItems are clickable and some are not. For those that are not clickable, I changed the Foreground color to gray. However, if that item has children, I want to also change the little triangular bullet to gray. How can I do that, something like this: //PSEUDO-CODE: <TreeViewItem IconBulletEnabled="False" IconBulletCo...

Highlight TextBlock only in TreeViewItem with Image

So I have a TreeViewItem that has the following style: <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="HeaderTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal"...

Silverlight: How to change TreeViewItem text color when it selected

I have TextBlock inside HierarchicalDataTemplate. I need to set foreground color to Red when TreeViewItem selected. <controls:TreeView Background="#FF939597" ScrollViewer.HorizontalScrollBarVisibility="Disabled" x:Name="CommentTreeView" Margin="0,0,0,118" ItemContainerStyle="{StaticResource SectionsTreeViewItemStyle}"...

WPF: Setting a binding for all TreeViewItem instance

Greetings, I'm using WPF with a Model-View-ViewModel pattern, and I have a view model with an IsSelected property which I want to bind to a TreeViewItem's IsSelected property for all TreeViewItems in the scope. I'm attempting to do this with a Style and a Setter. This works apparently for the root-level TreeViewItems, but not for their ...

WPF TreeView not collapsing its formerly used space on collapse of root root

Hello, I have some objects with various collection properties that I'm displaying in a ListBox using a DataTemplate for the ItemTemplate. Within that DataTemplate is a TreeView which displays various properties as TreeViewItem children of a root TreeViewItem which represents the items being displayed in the ListBoxItem. My problem is ...

WPF TreeViewItem + Change the Highlight Color

Hello, I have got a TreeView with a HierarchicalDataTemplate. <HierarchicalDataTemplate x:Key="treeViewItemTemplate" ItemsSource="{Binding GetChildren}"> <DockPanel Margin="0,8,8,0"> <Image Source="{Binding GetImage}" Width="16" Height="16" /> <local:MonitorTriStateCheckBox Margin="4,0,0,0" I...

wpf manually generate TreeViewItem container

I am creating a TreeView at runtime. It has several nodes(TreeViewItem), each one having a name. Initially it is collapsed. A separate comboBox displays Names of all TreeViewItem. I have to highlight a TreeViewItem based on the Name selected. I am using a recursive function and gets the TreeViewItem container like this: if (parent.ItemC...

WPF TreeViewItem deselected item still lightly highlighted

Hello WPF fellows, I have multiple expander controls with a ViewTree control within each expander control. When I select a ViewTreeItem from one ViewTree and then select another ViewTreeItem from another ViewTree, the newly selected ViewTreeItem is highlighted in dark blue, but the last selected item is now highlighted in a very light s...

Select Silverlight Treeview Item using MVVM Pattern

Can anyone tell me,Please include code, how to select a treeviewitem using the MVVM Pattern ...

Modifying an individual TreeViewItem on a databound WPF TreeView without modifying the data source.

I've got a MVVM WPF app with the TreeView databound to a viewmodel class. It is essentially a file explorer. I want to add the ability to "Add a new folder" to the hierarchy. To achieve the desired functionality what I am trying to do is simply switch the Textblock out for an editable TextBox in my datatemplate. This is what my datat...

WPF - attached behavior to capture MouseEnter on Image in TreeviewITem

Hi! Could I have, please, a little code-sample of WPF "attached behavior"? I explain my problem: I've done my TreeView all with XAML but now I'd like to manage an event with code-behind. The HierarchicalDataTemplate contains an Image. I need to capture the events MouseEnter / MouseLeave on the Image. I'd like to do this with "attache...