翻譯|使用教程|編輯:龔雪|2022-01-24 10:07:30.927|閱讀 273 次
概述:本文主要介紹如何使用標準DevExpress服務及MessageBoxService,歡迎下載最新版體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
DevExpress Services將命令從ViewModel傳遞到View中的控件,這允許您在不分離應用程序層的情況下修改 UI。
示例
C#
//1. Global registration MVVMContext.RegisterMessageBoxService(); //1. Local registration mvvmContext1.RegisterService(CreateXtraMessageBoxService()); //2. POCO ViewModel property that returns a Service protected virtual IMessageBoxService MessageBoxService { get { throw new System.NotImplementedException(); } } //3. Send a Service command to a View public void SayHello() { MessageBoxService.Show("Hello!"); }
VB.NET
'1. Global registration MVVMContext.RegisterMessageBoxService() '1. Local registration mvvmContext1.RegisterService(CreateXtraMessageBoxService()) '2. POCO ViewModel property that returns a Service protected virtual IMessageBoxService MessageBoxService Get Throw New System.NotImplementedException() End Get '3. Send a Service command to a View public void SayHello() MessageBoxService.Show("Hello!")
允許您顯示消息框和浮出控件。
接口
托管控件
全局注冊
C#
MVVMContext.RegisterMessageBoxService(); MVVMContext.RegisterXtraMessageBoxService(); MVVMContext.RegisterFlyoutMessageBoxService();
VB.NET
MVVMContext.RegisterMessageBoxService() MVVMContext.RegisterXtraMessageBoxService() MVVMContext.RegisterFlyoutMessageBoxService()
DevExpress MVVM 框架自動調用 RegisterXtraMessageBoxService 方法。
本地注冊
C#
mvvmContext1.RegisterService( //one of "Create" methods from the list below );
VB.NET
mvvmContext1.RegisterService( 'one of "Create" methods from the list below )
Create() 方法
所有四個方法都具有與第二個 IWin32Window 所有者參數對應的重載,此參數允許您指定擁有此服務的視圖。 如果您傳遞 null 而不是 owner 參數,則框架會嘗試找到應該是服務所有者的適當視圖。 在大多數情況下,使用激活窗口。
公共服務成員
C#
var msgService = MessageBoxService.CreateFlyoutMessageBoxService(); msgService.MessageBoxFormStyle = (form) => { { FlyoutDialog msgFrm = form as FlyoutDialog; msgFrm.Properties.AppearanceButtons.FontStyleDelta = FontStyle.Bold; };
VB.NET
Dim msgService = MessageBoxService.CreateFlyoutMessageBoxService(Me) msgService.DialogFormStyle = Sub(form) Dim msgFrm As FlyoutDialog = TryCast(form, FlyoutDialog) msgFrm.Properties.AppearanceButtons.FontStyleDelta = FontStyle.Bold End Sub
DevExpress WinForm擁有180+組件和UI庫,能為Windows Forms平臺創建具有影響力的業務解決方案。DevExpress WinForms能完美構建流暢、美觀且易于使用的應用程序,無論是Office風格的界面,還是分析處理大批量的業務數據,它都能輕松勝任!
更多產品正版授權詳情及優惠,歡迎咨詢
DevExpress技術交流群5:742234706 歡迎一起進群討論
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網