彈出對話框
Flyout Dialog提供了類似于彈出內(nèi)容容器的功能,允許您在應(yīng)用程序UI管理器組件的WindowsUI視圖中創(chuàng)建Windows 10風(fēng)格的彈出消息,但是Flyout Dialog允許在應(yīng)用程序中實(shí)現(xiàn)此功能,而無需使用任何其他組件。要顯示彈出式消息框或彈出窗口,只需在代碼中調(diào)用FlyoutDialog.Show方法。
C#:
DevExpress.XtraBars.Docking2010.Customization.FlyoutDialog.Show(. . .);
點(diǎn)擊復(fù)制
VB.NET:
DevExpress.XtraBars.Docking2010.Customization.FlyoutDialog.Show(. . .)
點(diǎn)擊復(fù)制
Show方法有多個重載。根據(jù)選擇的重載,必須將所有者、控件、彈出動作、彈出屬性和謂詞作為參數(shù)傳遞。
- Owner——將擁有顯示的彈出式消息框或彈出框的表,使用此關(guān)鍵字可將當(dāng)前表單設(shè)置為彈出框的父表單。
- Control——在彈出框中顯示的控件或UserControl對象,下圖展示了一個空白的彈出式窗口,其中包含一個WindowsUIButtonPanel。
 
 
FlyoutAction ——一個FlyoutAction對象,它包含標(biāo)題、描述、圖像和一組在這個彈出框中顯示的按鈕。下圖展示了一個示例。
 
 
下面的代碼創(chuàng)建了一個帶有自定義標(biāo)題、描述和兩個Flyout命令(' Close '和' Cancel ')的Flyout Action,它們具有特定的 DialogResult 值。
C#:
DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction action = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction() { Caption = "Confirm", Description = "Close the application?" };
DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand command1 = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() { Text = "Close", Result = System.Windows.Forms.DialogResult.Yes };
DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand command2 = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() { Text = "Cancel", Result = System.Windows.Forms.DialogResult.No };
action.Commands.Add(command1);
action.Commands.Add(command2);
	點(diǎn)擊復(fù)制
VB.NET:
Dim command1 As New DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() With { _
.Text = "Close", _
.Result = System.Windows.Forms.DialogResult.Yes _
}
Dim command2 As New DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() With { _
.Text = "Cancel", _
.Result = System.Windows.Forms.DialogResult.No _
}
action.Commands.Add(command1)
action.Commands.Add(command2)
	點(diǎn)擊復(fù)制
提示:如果將 和FlyoutAction傳遞給FlyoutDialog.Show方法,F(xiàn)lyoutAction的標(biāo)題和按鈕將被顯示,而描述和圖像將被隱藏。
Flyout Properties——一個 DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutProperties對象,用于存儲顯示的彈出框的高級屬性。例如,下面代碼中的Style屬性允許您選擇彈出樣式(在整個表單中顯示的消息框或彈出窗口),ButtonSize屬性設(shè)置自定義動作按鈕的大小。
C#:
FlyoutProperties properties = new FlyoutProperties(); properties.ButtonSize = new Size(100, 40); properties.Style = FlyoutStyle.MessageBox;
點(diǎn)擊復(fù)制
VB.NET:
Dim properties As New FlyoutProperties() properties.ButtonSize = New Size(100, 40) properties.Style = FlyoutStyle.MessageBox
點(diǎn)擊復(fù)制
Predicate——引用一個布爾函數(shù)的謂詞,該函數(shù)接受一個DialogResult 值作為參數(shù)。該函數(shù)根據(jù)彈出框的輸出DialogResult 指定是否可以關(guān)閉彈出框,謂詞強(qiáng)制最終用戶單擊彈出按鈕,從而確保彈出不會通過任何其他方式關(guān)閉(例如,按“Esc”按鈕)。下面的代碼演示了一個示例。
C#:
Predicate<DialogResult> predicate = canCloseFunc;
private static bool canCloseFunc(DialogResult parameter) {
return parameter != DialogResult.Cancel;
}
	點(diǎn)擊復(fù)制
VB.NET:
Private predicate As Predicate(Of DialogResult) = AddressOf canCloseFunc Private Shared Function canCloseFunc(ByVal parameter As DialogResult) As Boolean Return parameter <> DialogResult.Cancel End Function
點(diǎn)擊復(fù)制
Show方法返回 DialogResult枚舉器值,該值允許檢查單擊了哪個FlyoutCommand。使用這個和上面的信息,您可以在父表單關(guān)閉時顯示一個彈出對話框,如下面的代碼所示。這段代碼顯示了一個帶有兩個按鈕的彈出消息框,使用的謂詞確保flyout只有在終端用戶在“Close”和“Cance”選項(xiàng)之間選擇后才會關(guān)閉。
C#:
private static bool canCloseFunc(DialogResult parameter) {
return parameter != DialogResult.Cancel;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction action = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction() { Caption = "Confirm", Description = "Close the application?" };
Predicate<DialogResult> predicate = canCloseFunc;
DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand command1 = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() { Text = "Close", Result = System.Windows.Forms.DialogResult.Yes };
DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand command2 = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() { Text = "Cancel", Result = System.Windows.Forms.DialogResult.No };
action.Commands.Add(command1);
action.Commands.Add(command2);
FlyoutProperties properties = new FlyoutProperties();
properties.ButtonSize = new Size(100, 40);
properties.Style = FlyoutStyle.MessageBox;
if (FlyoutDialog.Show(this, action, properties, predicate) == System.Windows.Forms.DialogResult.Yes) e.Cancel = false;
else e.Cancel = true;
}
	點(diǎn)擊復(fù)制
VB.NET:
Private Shared Function canCloseFunc(ByVal parameter As DialogResult) As Boolean
Return parameter IsNot DialogResult.Cancel
End Function
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
Dim action As New DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction() With {.Caption = "Confirm", .Description = "Close the application?"}
Dim predicate As Predicate(Of DialogResult) = AddressOf canCloseFunc
Dim command1 As New DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() With {.Text = "Close", .Result = System.Windows.Forms.DialogResult.Yes}
Dim command2 As New DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() With {.Text = "Cancel", .Result = System.Windows.Forms.DialogResult.No}
action.Commands.Add(command1)
action.Commands.Add(command2)
Dim properties As New FlyoutProperties()
properties.ButtonSize = New Size(100, 40)
properties.Style = FlyoutStyle.MessageBox
If FlyoutDialog.Show(Me, action, properties, predicate) = System.Windows.Forms.DialogResult.Yes Then
e.Cancel = False
Else
e.Cancel = True
End If
End Sub
	點(diǎn)擊復(fù)制

 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網(wǎng)安備
            50010702500608號
渝公網(wǎng)安備
            50010702500608號
             
            
 客服熱線
客服熱線