IsExpanded Property
Collapse the table of content
Expand the table of content

TreeViewItem.IsExpanded Property

Gets or sets whether the nested items in a TreeViewItem are expanded or collapsed.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public bool IsExpanded { get; set; }
/** @property */
public boolean get_IsExpanded ()

/** @property */
public void set_IsExpanded (boolean value)

public function get IsExpanded () : boolean

public function set IsExpanded (value : boolean)

<object IsExpanded="bool" .../>

Property Value

true if the nested items of a TreeViewItem are visible; otherwise, false. The default value is false.

Identifier Field

IsExpandedProperty

Metadata Flags

None

The appearance of the button that expands and collapses the TreeViewItem changes when the TreeViewItem is expanded or collapsed. When the IsExpanded property value changes from true to false, the Collapsed event occurs. Similarly, the Expanded event occurs when the IsExpanded property value changes from false to true.

The following example shows how to set the IsExpanded property.

<TreeViewItem Header="Employee1"
              Name="Employee1Data" 
              IsExpanded="True" 
              Collapsed="OnCollapsed" 
              Expanded="OnExpanded">
  <TreeViewItem Header="Work Days" 
                Name="EmployeeWorkDays"
                IsSelected="True">
    <TreeViewItem Header="Tuesday" />
    <TreeViewItem Header="Friday"/>
  </TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="Employee2" 
              Name="Employee2Data">
  <TreeViewItem Header="Work Days" 
                Name="emp2WorkDays" 
                Selected="GetSchedule"
                Unselected="SetSchedule">
    <TreeViewItem Header="Monday" />
    <TreeViewItem Header="Wednesday"/>
  </TreeViewItem>
</TreeViewItem>

Employee1Data.IsExpanded = true;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2016 Microsoft