This is a migrated thread and some comments may be shown as answers.

Styling individual items in tree

2 Answers 124 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 13 Oct 2011, 10:41 AM
Hi telerik,

The users of our MVVM application would like items to be 'marked' in various ways; a combination of italics and bold is desired.

Currently, we style the items as shown below, reacting to changes in IsSelected.

The other thing we would like to react on is whether the treeitem's editor (in another window) is given focus, but of course there is no relevant RadTreeViewItem property to bind to - how would you go about this? Can we intercept the styling somehow and for each item - in code-as-opposed-to-markup - apply the style as we see fit?

Thanks for any input,

Anders, Denmark

 

 

 

<Controls:RadTreeView.ItemContainerStyle>

 

 

 

 

<Style TargetType="{x:Type Controls:RadTreeViewItem}">

 

 

 

 

<Setter Property="WorkspaceExplorer:MouseDoubleClickBehavior.MouseDoubleClick" Value="{Binding ActivateItemCommand}" />

 

 

 

 

<Setter Property="Margin" Value="0"/>

 

 

 

 

<Setter Property="Padding" Value="0"/>

 

 

 

 

<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />

 

 

 

 

<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />

 

 

 

 

<Setter Property="FontWeight" Value="Normal" />

 

 

 

 

<Style.Triggers>

 

 

 

 

<Trigger Property="IsSelected" Value="True">

 

 

 

 

<Setter Property="FontWeight" Value="Bold" />

 

 

 

 

</Trigger>

 

 

 

 

</Style.Triggers>

 

 

 

 

</Style>

 

 

 

 

</Controls:RadTreeView.ItemContainerStyle>

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 18 Oct 2011, 10:48 AM
Hi Anders,

Basically at any time you can set the RadTreeViewItem.Style or the RadTreeView.ItemContainerStyle properties. And when the window for editing the item is opened you can apply a custom style to the RadTreeViewItem that is edited. Also, the RadTreeView control exposes also an ItemContainerStyleSelector property that gives you the ability to change the style for the RadTreeViewItems based on custom logic like a data property value, for example.

I hope this info will help you implement your scenario. However, since I am not sure if I properly understand it, if I am missing something, please send us a sample code/solution demonstrating your requirements and scenario. Then we will be able to look further into it and find other approaches.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Anders
Top achievements
Rank 1
answered on 05 Jan 2012, 09:58 AM
Better late than never -- finally got back to this assignment -- and found your reply useful.

Thanks,
Anders, Denmark.
Tags
TreeView
Asked by
Anders
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Anders
Top achievements
Rank 1
Share this question
or