翻譯|使用教程|編輯:龔雪|2022-01-24 10:07:30.927|閱讀 273 次
概述:本文主要介紹如何使用標(biāo)準(zhǔn)DevExpress服務(wù)及MessageBoxService,歡迎下載最新版體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
DevExpress Services將命令從ViewModel傳遞到View中的控件,這允許您在不分離應(yīng)用程序?qū)拥那闆r下修改 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 框架自動調(diào)用 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 所有者參數(shù)對應(yīng)的重載,此參數(shù)允許您指定擁有此服務(wù)的視圖。 如果您傳遞 null 而不是 owner 參數(shù),則框架會嘗試找到應(yīng)該是服務(wù)所有者的適當(dāng)視圖。 在大多數(shù)情況下,使用激活窗口。
公共服務(wù)成員
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平臺創(chuàng)建具有影響力的業(yè)務(wù)解決方案。DevExpress WinForms能完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序,無論是Office風(fēng)格的界面,還是分析處理大批量的業(yè)務(wù)數(shù)據(jù),它都能輕松勝任!
更多產(chǎn)品正版授權(quán)詳情及優(yōu)惠,歡迎咨詢
DevExpress技術(shù)交流群5:742234706 歡迎一起進群討論
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)