Visibility Enumeration

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Specifies the display state of an element.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Enumeration Visibility
public enum Visibility
<object property="enumMemberName"/>

Members

Member name Description
Supported by Silverlight for Windows Phone Visible Display the element.
Supported by Silverlight for Windows Phone Collapsed Do not display the element, and do not reserve space for it in layout.

Remarks

Elements that have a Visibility value of Collapsed do not occupy any layout space. By default, elements are Visible.

WPF has a Visibility state of Hidden. Silverlight does not support the Hidden Visibility state. If you are migrating XAML UI definitions from WPF XAML, you will have to edit any cases that attempt to set a Visibility to Hidden.

Visibility in a Visual State

As part of defining visual states for a control, you will sometimes want to change the Visibility state of an object to Hidden. Visual states rely on animations. The property value type of UIElement.Visibility is Visibility, an enumeration. To animate values that are enumerations, you must use a DiscreteObjectKeyFrame.

The following XAML example shows a visual state that uses DiscreteObjectKeyFrame to change visibility.

<VisualState x:Name="Focused">
  <Storyboard>
    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility" Duration="0">
      <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
    </ObjectAnimationUsingKeyFrames>
  </Storyboard>
</VisualState>

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources