Silverlight - 彈出視窗



此類在應用程式視窗的範圍內,在現有內容之上顯示內容。它是對其他內容的臨時顯示。Popup類的層次繼承如下:

Inheritance of Popup

以下是Popup類常用的屬性

序號 屬性及描述
1

Child

獲取或設定要在彈出視窗中託管的內容。

2

ChildProperty

獲取Child依賴屬性的識別符號。

3

ChildTransitions

獲取或設定應用於Popup子內容的Transition樣式元素的集合。

4

ChildTransitionsProperty

標識ChildTransitions依賴屬性。

5

HorizontalOffset

獲取或設定應用程式視窗左側與彈出視窗左側之間的距離。

6

HorizontalOffsetProperty

獲取HorizontalOffset依賴屬性的識別符號。

7

IsLightDismissEnabled

獲取或設定一個值,該值確定如何關閉彈出視窗。

8

IsLightDismissEnabledProperty

標識IsLightDismissEnabled依賴屬性。

9

IsOpen

獲取或設定彈出視窗當前是否顯示在螢幕上。

10

IsOpenProperty

獲取IsOpen依賴屬性的識別符號。

11

VerticalOffset

獲取或設定應用程式視窗頂部與彈出視窗頂部之間的距離。

12

VerticalOffsetProperty

獲取VerticalOffset依賴屬性的識別符號。

Popup類具有以下事件

序號 事件及描述
1

Closed

當IsOpen屬性設定為false時觸發。

2

Opened

當IsOpen屬性設定為true時觸發。

下面給出一個簡單的示例,其中建立並初始化了一個Popup控制元件和一個CheckBox。當用戶選中CheckBox時,它將顯示一個Popup

<UserControl x:Class = "Popup.MainPage" 
   xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" 
   xmlns:d = "http://schemas.microsoft.com/expression/blend/2008" 
   xmlns:mc = "http://schemas.openxmlformats.org/markup-compatibility/2006" 
   mc:Ignorable = "d" 
   d:DesignHeight = "300" d:DesignWidth = "400"> 
   
   <Grid x:Name = "LayoutRoot" Background = "White">
	
      <CheckBox Name = "PCheckBox" Margin = "0,100,296,172" Content = "Checked Me"/>
		
      <Popup IsOpen = "{Binding ElementName = PCheckBox,Path = IsChecked}"> 
		
         <Canvas Width = "125" Height = "100" Background = "LightGray"> 
            <Canvas.RenderTransform> 
               <RotateTransform x:Name = "theTransform" /> 
            </Canvas.RenderTransform>
				
            <TextBlock TextWrapping = "Wrap" Foreground = "Blue" Text = "Hi, 
               this is Popup"/> 
         </Canvas>
			
      </Popup>  
		
   </Grid> 
	
</UserControl> 

編譯並執行上述程式碼後,您將看到以下輸出。當您選中複選框時,它將顯示彈出視窗。

CheckBox of Popup
silverlight_listbox.htm
廣告