Visibility Property
Gets or sets the user interface (UI) visibility of this element.
XAML |
<object Visibility="Visibility" .../>
|
Scripting |
value = object.Visibility object.Visibility = value |
Property Value
A value of the Visibility enumeration.
This property is read/write. The default value is Visible.
Remarks
Elements where Visibility is not Visible do not participate in input events (or commands), are not in a tab sequence, and are excluded during hit testing.
Note 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 elements that would otherwise be hit testable by virtue of the Visibility and Background property values.
Examples
The following XAML example shows how to set the Visibility property of a TextBlock to Visible:
XAML |
---|
<Canvas xmlns="https://schemas.microsoft.com/client/2007" Background="Wheat"> <TextBlock Text="Click me!" Visibility="Visible" Canvas.Left="20" FontSize="24" MouseLeftButtonUp="onMouseLeftButtonUp" /> </Canvas> |
The following JavaScript example shows how to set the Visibility property of the TextBlock to Hidden:
JavaScript |
---|
function onMouseLeftButtonUp(sender, mouseEventArgs) { // TextBlock collapsed sender.visibility = "Collapsed"; // The IsHitTestVisible property is ignored during hit testing, // it is still set to true for an element whose Visibility is Collapsed, has null or Transparent Brush, or Opacity=0. alert(sender.isHitTestVisible); } |
Applies To
Canvas, Ellipse, Glyphs, Image, InkPresenter, Line, MediaElement, Path, Polygon, Polyline, Rectangle, TextBlock