SilverLight的TreeView控件如何用程序设置某节点的选中状态,如何用程序展开某节点? RRS feed



    private void Button_Click(object sender, RoutedEventArgs e)



    TreeViewItem t= TreeView1.Items[1] as TreeViewItem;

    t.IsExpanded = !t.IsExpanded;







    <Button Width="100" Height="30" Click="Button_Click"></Button>



    <controls:TreeView x:Name="TreeView1">



    <controls:TreeViewItem Header="John"/>



    <controls:TreeViewItem Header="Greg" IsExpanded="True">



    <controls:TreeViewItem Header="Linda"/>



    <controls:TreeViewItem Header="Darren"/>






    <controls:TreeViewItem Header="Allice" IsExpanded="True">



    <controls:TreeViewItem Header="Neil"/>










    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • 已标记为答案 子龙 2009年9月27日 3:29
    2009年9月25日 9:29