2015-11-06 41 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>