语言

Popup.StaysOpen 属性

定义

获取或设置一个值,该值指示当控件不再处于焦点时控件是否 Popup 关闭。

public:
 property bool StaysOpen { bool get(); void set(bool value); };
[System.ComponentModel.Bindable(true)]
public bool StaysOpen { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.StaysOpen : bool with get, set
Public Property StaysOpen As Boolean

属性值

true Popup如果控件在属性设置为IsOpen关闭时false关闭;false如果Popup控件在控件外部Popup发生鼠标或键盘事件时关闭,则为 。 默认值为 true。

特性

示例

以下示例演示如何设置 StaysOpen 属性。

myTextBlockPopup.StaysOpen = true;
myTextBlockPopup.StaysOpen = True
<DockPanel  Width="500" Background="Aqua">
  <Popup Placement="Center" PlacementRectangle="0,0,30,50"  
          IsOpen ="True" StaysOpen="True"
          PopupAnimation="Fade">
    <TextBlock Background="Purple">Popup Text</TextBlock>
  </Popup>
</DockPanel>

注解

如果属性StaysOpen设置为true,Popup则保持打开状态,直到将属性设置为IsOpenfalse显式关闭。 当 StaysOpen 是 false时,控件 Popup 将截获所有鼠标和键盘事件,以确定其中一个事件发生在 Popup 控件外部。

Dependency 属性信息

项目 价值
标识符字段 StaysOpenProperty
元数据属性设置为 true None

适用于

另请参阅