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

Binding to IsExpanded

2 Answers 114 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 07 Dec 2011, 12:28 PM
Hello.

I've read several forum entries concerning this and it does not sound good:
"and with latest versions of RadTreeListView binding to IsExpanded is not supported."
After this I've read something about StyleSelectors and some other stuff about RowLoaded events...

So, my question: What is the best way to do it with the current version?
Thanks a lot for any kind of information!!!

All the best,
Tim.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 08 Dec 2011, 05:17 PM
Hi Tim,

 
You could  bind the "IsExpanded" property using a RowStyleSelector like so: 

1. Create a StyleSelector (you need to have a property IsExpanded for the bound item):

public class CustomStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            if(container is TreeListViewRow)
            {
    
                if(item is ClientCategory)
                {
                    Style style = new Style() { TargetType=typeof(TreeListViewRow)};
    
                    style.Setters.Add(new Setter(TreeListViewRow.IsExpandedProperty, ((ClientCategory)item).IsExpanded));
    
                    return style;
                }
            }
            return base.SelectStyle(item, container);
        }
    }

2. Then apply this style as a RowStyleSelector for the TreeListView:

<Grid.Resources>
            <local:CustomStyleSelectorx:Key="CustomSelector"/>
</Grid.Resources>  ...
<telerik:RadTreeListView x:Name="tlv" RowStyleSelector="{StaticResource CustomSelector}"/>

This is the best way to do it with the current version.

All the best,
Didie
the Telerik team

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

0
Tim
Top achievements
Rank 1
answered on 08 Dec 2011, 05:35 PM
Didie, thanks A LOT!!!
All the best,Tim.
Tags
TreeListView
Asked by
Tim
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Tim
Top achievements
Rank 1
Share this question
or