2015-11-06 96 views

回答

0

对于自动刷新,您可以为treeView创建一些ViewModel。就像我的回答Binding a WPF TreeView to multiple Lists。要更新所选项目并将其展开,您应该在ViewModelIsSelectedIsExpanded属性(如Name属性,但是bool)中定义。你应该在你的TreeView这样定义ItemContainerStyle

<TreeView.ItemContainerStyle> 
    <Style TargetType="{x:Type TreeViewItem}"> 
     <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/> 
     <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/> 
     <Setter Property="HorizontalAlignment" Value="Left"/> 
    </Style> 
</TreeView.ItemContainerStyle>