Popup.IsOpen 属性


获取或设置一个值,该值指示 Popup 是否可见。Gets or sets a value that indicates whether the Popup is visible.

 property bool IsOpen { bool get(); void set(bool value); };
public bool IsOpen { get; set; }
member this.IsOpen : bool with get, set
Public Property IsOpen As Boolean


如果 Popup 可见,则为 true;否则为 falsetrue if the Popup is visible; otherwise, false. 默认值为 falseThe default is false.



下面的示例演示如何设置 IsOpen 属性。The following example shows how to set the IsOpen property.

myPopupIsOpen.IsOpen = true;
myPopupIsOpen.IsOpen = True
<Popup Name="myPopupIsOpen" IsOpen="True" 
       HorizontalOffset=".5cm" VerticalOffset="1cm">
  <TextBlock Background="Yellow">Popup Text</TextBlock>


如果控件使用Popup作为其默认样式的一部分, 请将的IsOpen Popup属性绑定到控件的属性。If a control uses a Popup as part of its default style, bind the IsOpen property of the Popup to a property of the control. 例如, 可以将ComboBoxIsDropDownOpen属性绑定到IsOpenPopup属性。For example, a ComboBox can bind its IsDropDownOpen property to the IsOpen property of the Popup. 这简化了逻辑, 以便控制何时Popup可见。This simplifies the logic for controlling when the Popup is visible.

依赖项属性信息Dependency Property Information

标识符字段Identifier field IsOpenProperty
元数据属性设置为trueMetadata properties set to true BindsTwoWayByDefault