The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElement.Visibility Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the visibility of a UIElement. A UIElement that is not visible does not render and does not communicate its desired size to layout.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public Visibility Visibility { get; set; }
<uiElement Visibility="Visible"/>
<uiElement Visibility="Collapsed"/>

Property Value

Type: System.Windows.Visibility
A value of the enumeration. The default value is Visibility.Visible.

Dependency property identifier field: VisibilityProperty

Elements where Visibility is not Visible do not participate in input events, are not in a tab sequence (cannot be focused), and are excluded during hit testing.


The value of IsHitTestVisible is ignored when an object is not set to Visible. IsHitTestVisible is a settable property that enables you to disable hit testing for objects that would otherwise be hit testable by virtue of the Visibility and Background property values.

Windows Phone does not support a Visibilty value of Hidden.

For more information on the XAML syntax, see Visibility.

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 Collapsed. 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. (You also use this technique for Boolean values).

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

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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone