.NET Framework Class Library
UIElementVisibility Property

Gets or sets the user interface (UI) visibility of this element. This is a dependency property.

Namespace:   System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax
<[%$TOPIC/ms588755_en-us_VS_110_1_0_0_0_0%]([%$TOPIC/ms588755_en-us_VS_110_1_0_0_0_1%].None, Readability := [%$TOPIC/ms588755_en-us_VS_110_1_0_0_0_2%].Unreadable)> _
Public Property Visibility As [%$TOPIC/ms588755_en-us_VS_110_1_0_0_0_3%]
[[%$TOPIC/ms588755_en-us_VS_110_1_0_1_0_0%]([%$TOPIC/ms588755_en-us_VS_110_1_0_1_0_1%].None, Readability = [%$TOPIC/ms588755_en-us_VS_110_1_0_1_0_2%].Unreadable)]
public [%$TOPIC/ms588755_en-us_VS_110_1_0_1_0_3%] Visibility { get; set; }
[[%$TOPIC/ms588755_en-us_VS_110_1_0_2_0_0%]([%$TOPIC/ms588755_en-us_VS_110_1_0_2_0_1%]::None, Readability = [%$TOPIC/ms588755_en-us_VS_110_1_0_2_0_2%]::Unreadable)]
public:
property [%$TOPIC/ms588755_en-us_VS_110_1_0_2_0_3%] Visibility {
	[%$TOPIC/ms588755_en-us_VS_110_1_0_2_0_4%] get ();
	void set ([%$TOPIC/ms588755_en-us_VS_110_1_0_2_0_5%] value);
}
[<[%$TOPIC/ms588755_en-us_VS_110_1_0_3_0_0%]([%$TOPIC/ms588755_en-us_VS_110_1_0_3_0_1%].None, Readability = [%$TOPIC/ms588755_en-us_VS_110_1_0_3_0_2%].Unreadable)>]
member Visibility : [%$TOPIC/ms588755_en-us_VS_110_1_0_3_0_3%] with get, set
<object Visibility="[%$TOPIC/ms588755_en-us_VS_110_1_0_4_0_0%]" .../>

Property Value

Type: System.WindowsVisibility
A value of the enumeration. The default value is Visible.
Dependency Property Information

Identifier field

VisibilityProperty

Metadata properties set to true

None

Remarks

Setting this property affects the value of IsVisible, which in turn may raise the IsVisibleChanged event. However, IsVisible has other factors that influence it, for instance the visibility settings of parents that contain it.

Elements where Visibility is not Visible do not participate in input events (or commands), do not influence either the Measure or Arrange passes of layout, are not in a tab sequence, and will not be reported in hit testing.

When inherited by Window or its derived classes, Window redefines the default value of this property to be Collapsed. This has the effect of not running the Measure pass of layout on an initially created Window, and RenderSize returns (0,0). For details, see Window. Popup also redefines the default value to be Collapsed, with similar resulting behavior for Popup and its derived classes.

Examples

The following example implements a handler that references two different named buttons that are intended to be a mutually exclusive pair in the user interface. Prior to running the actual program logic associated with the button, the button itself is set to be VisibilityHidden, and the other button in the pair is set to VisibilityVisible.

Private Sub PlayMedia(ByVal sender As Object, ByVal args As MouseButtonEventArgs)
            pauseBTN.Visibility = System.Windows.Visibility.Visible
            playBTN.Visibility = System.Windows.Visibility.Collapsed

            media.SpeedRatio = 1.0
            media.Play()

        End Sub 'PlayMedia
private void PlayMedia(object sender, MouseButtonEventArgs args)
{
    pauseBTN.Visibility = Visibility.Visible;
    playBTN.Visibility = Visibility.Collapsed;

    media.SpeedRatio = 1.0;
    media.Play();
}
Version Information

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.