Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Row expansion bind two way , MVVM
posted

I have requirement to read expansion information of each tree node and save and apply it when tree is refreshed.

I came across this link https://ko.infragistics.com/community/forums/p/37606/218290.aspx, which work when tree loads.

The following code sets IsExpandedAll property,

<igWpf:XamTreeGrid DataSource="{Binding Path=TreeItems}" 
                           infratreegrid:XamTreeGridBehaviour.IsExpandedAll="{Binding IsExpandedAll}">

I am not able to figure out how to send expansion information back to viewmodel

Thanks

JS

  • 16495
    Offline posted

    Hello JS,

    If I understood correctly you want to bind the expanded state of each node to some property from your ViewModel. If my assumption is correct I suggest to use the approach that was used on the following thread:

    https://ko.infragistics.com/community/forums/t/105515.aspx

    You can create a style for TreeCellValuePresenter and bind it's IsExpanded property to what you want:

     <Style TargetType="{x:Type ig:TreeCellValuePresenter}">
         <Setter Property="IsExpanded" Value="{Binding DataItem.IsOpen,Mode=TwoWay}"/>
     </Style>
     

    Let me know if you need from any further assistance.

    Sincerely,
    Zhivko
    Associate Software Developer