賞金將在 2 天內到期。此問題的答案有資格獲得 50聲望賞金。 克爾斯滕想引起更多人對這個問題的關注。
用戶經常在監視器之間移動我的 XAF Winforms 應用程式。但是,由PopUpWindowShowAction呼叫的對話框仍保留在舊監視器上
這個問題可以通過 Dev Express 的 Main Demo 重復(盡管要在那里除錯它,我認為我需要進入 API 代碼)。
- 運行 Main Demo 并將應用程式視窗移動到第二個監視器。
- 選擇用戶,右鍵單擊用戶并選擇列印預覽。
列印預覽將出現在第一臺顯示幕上。
在我的類似情況下,我的控制器是
public partial class JobHeadFilterController : ViewController, IClassicController
{
public JobHeadFilterController()
{
InitializeComponent();
TargetViewNesting = Nesting.Root;
}
protected override void OnActivated()
{
base.OnActivated();
popupWindowShowFilterAction.QuickAccess = true;
}
private void popupWindowShowFilterAction_CustomizePopupWindowParams(object sender,
CustomizePopupWindowParamsEventArgs e)
{
var holder = new JobHeadFilterHolder();
var npProvider = new NonPersistentObjectSpaceProvider(XafTypesInfo.Instance, null);
var os = (NonPersistentObjectSpace)npProvider.CreateObjectSpace();
var view = Application.CreateDetailView(os, holder);
e.View = view;
}
我嘗試瀏覽 CustomizePopupWindowParamsEventArgs 的屬性,但看不到要設定的內容。
我可以使用
var mainform = Application.MainWindow.Template as Form;
我想我需要在 popupWindowShowFilterAction_CustomizePopupWindowParams 中執行以下操作
var template = e.Application.MainWindow.Template;
var window = new Window(Application, ); // having trouble figuring out the parameters
e.DialogController.SetWindow(window);
研究檔案
[更新]
我試過了
var window = e.Application.MainWindow; e.DialogController.SetWindow(視窗);
但出現錯誤
“DevExpress.ExpressApp.SystemModule.DialogController”控制器處于活動狀態。
我嘗試讓我自己的對話框控制器繼承自 DevExpress.ExpressApp.SystemModule.DialogController 但得到了同樣的錯誤。
uj5u.com熱心網友回復:
using System;
using System.Windows.Forms;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Templates;
using DevExpress.ExpressApp.Win.Templates;
namespace MyNameSpace;
public partial class CustomizeFormsWindowController : WindowController
{
public CustomizeFormsWindowController()
{
InitializeComponent();
TargetWindowType = WindowType.Child;
}
protected override void OnActivated()
{
base.OnActivated();
Window.TemplateChanged = WindowsTemplateChanged;
}
private void WindowsTemplateChanged(object sender, EventArgs e)
{
if (Window.Template is Form &&
Window.Template is ISupportStoreSettings)
((ISupportStoreSettings)Window.Template).SettingsReloaded =
OnFormReadyForCustomizations;
}
private void OnFormReadyForCustomizations(object sender, EventArgs e)
{
if (sender is not PopupForm popupForm) return;
var mainForm = Application.MainWindow.Template as Form;
var X = mainForm.Location.X (mainForm.Width - popupForm.Width) / 2;
var Y = mainForm.Location.Y (mainForm.Height - popupForm.Height) / 2;
popupForm.SetDesktopLocation(X, Y);
}
protected override void OnDeactivated()
{
Window.TemplateChanged -= WindowsTemplateChanged;
base.OnDeactivated();
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/450331.html
上一篇:winformsMDI在Windows11中具有新的最小子大小?
下一篇:如何將彈出選單定位到按鈕的左側?
