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

TreeListView IsExpanded OneWay binding

7 Answers 176 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Mickaël
Top achievements
Rank 1
Mickaël asked on 28 Mar 2012, 10:03 AM
In a current project, we've used the TreeListView to display hierachical data (sreenshot attached).

What we want to do is to expand all lines of a specific level.
For example (see screenshot) :
 > when the user clicks on button "1", all "level 1" lines should expand
 > when the user clicks on button "2", all "level 1 and 2" lines should expand
etc.

We've succeeded doing this scenario with a Style Selector (already used for background coloration) :

<styleSelectors:ConditionalStyleSelector.Level1Style>
     <Style TargetType="telerik:TreeListViewRow">
          <Setter Property="Background" Value="#6699FF" />
          <Setter Property="IsExpanded" Value="{Binding Path=IsExpandedLevel1, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=TwoWay}" />
     </Style>
</styleSelectors:ConditionalStyleSelector.Level1Style>

However, when the user collapses one "level 2" line (for example) all "level 2" lines are collasped.
So we've changed the binding mode to "OneWay" :

<Setter Property="IsExpanded" Value="{Binding Path=IsExpandedLevel1, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=OneWay}" /> 

However, with mode "OneWay" it doesn't work ...

Any idea ? Or sample code to do this ?

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 02 Apr 2012, 09:29 AM
Hello,

 Maybe you should rework the logic for collapsing in your model instead changing the binding from TwoWay to OneWay?

Kind regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Mickaël
Top achievements
Rank 1
answered on 02 Apr 2012, 06:35 PM
Hello,

Certainly we can do some rework. However, I was wondering why the "OneWay" mode doesn't work as excepted.
Do you have a bug logged on this ? Do you have a plan to correct it ? Any workaround ?

Thanks
Mickaël
0
Vlad
Telerik team
answered on 03 Apr 2012, 07:12 AM
Hello,

We are not sure if this is a bug in the component or something wrong with the logic behind this binding. Please send us an example demonstrating the problem - we will review your implementation and we will let you know about our findings. 

Regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Mickaël
Top achievements
Rank 1
answered on 10 Apr 2012, 06:28 PM
Hello,

Thanks for your answer.
Please find a "quick and dirty" sample to reproduce this behavior on : https://skydrive.live.com/redir.aspx?cid=541ade983cd620b1&resid=541ADE983CD620B1!151&parid=541ADE983CD620B1!149&authkey=!AF8cT2J0N5rWZK0

TwoWay binding is put on level 1. But, when the user collapses one "level 1" line (for example) all "level 1" lines are collasped.)
OneWay binding is put on level 2. But rows don't collapse when user clicks on button 2.

Thanks
Mickaël
0
Vera
Telerik team
answered on 11 Apr 2012, 03:44 PM
Hi Mickaël,

 
Actually, the behavior in both cases is expected. When TwoWay binding is set and a particular level is collapsed using the expander, the IsExpanded value is changed and all the rows from that level are collapsed. When OneWay binding is used, collapsing using the expander affects only the chosen row. But in that case you cannot use the implemented logic for the buttons' click events because it will not result in expanding/collapsing the items.
You can find some more information here.


Greetings,

Vera
the Telerik team

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

0
Mickaël
Top achievements
Rank 1
answered on 11 Apr 2012, 04:17 PM
Hello,

Thanks for this answer. However I really don't understand why this is the expected behavior
In the OneWay mode, when the source changes (ie: the ViewModel) then the target property should be updated. This is not the case for "IsExpanded" property.

Moreover, it works perfectly if you use "IsEnabled" property instead of "IsCollapsed".
Any other explanations ?

Regards,
Mickaël
0
Vera
Telerik team
answered on 12 Apr 2012, 01:25 PM
Hello Mickaël,


I have modified your project in order to demonstrate how the logic you have implemented works with MS TreeView. As you can see, the behavior is the same as the one when TreeListView is used. When OneWay mode is set, changing the IsExpanded value will affect the items only in case you have not expanded/collapsed them using the expander. You will need to revise your logic in order to achieve your goal.

 
Greetings,
Vera
the Telerik team

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

Tags
TreeListView
Asked by
Mickaël
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Mickaël
Top achievements
Rank 1
Vera
Telerik team
Share this question
or