Silverlight的TreeView控件默认是折叠的,如何默认展开节点呢?

如果不是绑定的好办,循环设置TreeViewItem.IsExpanded=true;即可。

如果是绑定的,例如用了MVVM,可以这样写:

<Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <Style x:Key="treeViewStyle" TargetType="sdk:TreeViewItem">
                <Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
            </Style>
        </Grid.Resources>

        <sdk:TreeView ItemContainerStyle="{StaticResource treeViewStyle}" ItemsSource="{Binding}" BorderThickness="0" 
         x:Name="myTreeView" />

    </Grid>

 

相关文章:

  • 2022-01-06
  • 2021-05-27
  • 2021-07-10
  • 2022-01-08
  • 2022-02-09
  • 2021-07-14
  • 2021-10-24
  • 2022-12-23
猜你喜欢
  • 2021-08-09
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
相关资源
相似解决方案