Save WPF TreeView state on data reload

前端 未结 1 1302
北海茫月
北海茫月 2021-01-18 07:50

I am using TreeView to display my data in UI. Now my application refreshes every 5 seconds so that it shows the most current data. Is there a way I can save my expanded stat

相关标签:
1条回答
  • 2021-01-18 08:12

    I solved that problem by adding IsExpanded and IsSelected properties to the object that my TreeView was bound to

    <Style TargetType="{x:Type TreeViewItem}">
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
    </Style>
    
    0 讨论(0)
提交回复
热议问题