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
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
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
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
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
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,
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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
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 >>