从 VSTO Outlook 加载项生成的居中 WPF 对话框
我正在开发一个 Outlook 2010 加载项,它提供了一个用于用户输入的对话框。在功能区中显示按钮所需的代码位于其自己的 Outlook 2010 加载项项目中。该项目引用了负责大部分工作的 WPF 用户控件库。
我在 WPF 用户控件库项目中使用静态方法,该方法负责正确配置 Caliburn.Micro 并显示对话框。所有这些都按预期工作,只是我无法弄清楚如何正确定位对话框。我希望它显示在 Outlook 窗口的中央。我知道我可以访问 Microsoft.Office.Interop.Outlook.Application.ActiveWindow()
,但我不知道这对我有何帮助,因为我无法将其转换为 PlacementTarget
code> 正如 Caliburn.Micro WindowManager 的 ShowDialog 方法的设置中所预期的那样。
WPF 用户控件库
namespace WpfUserControlLibrary {
public static class Connector {
public static void ShowDialog() {
new AppBootstrapper();
var windowManager = IoC.Get<IWindowManager>();
windowManager.ShowDialog( new ShellViewModel() );
}
}
}
Outlook 2010 加载项
WpfUserControlLibrary.Connector.ShowDialog();
I'm working on an Outlook 2010 add-in that provides a dialog for user input. The code necessary for displaying the button in the ribbon is in its own Outlook 2010 Add-in project. That project has a reference to a WPF User Control Library that is responsible for the bulk of the work.
I use a static method in the WPF User Control Library project that is responsible for configuring Caliburn.Micro correctly and displaying the dialog. All of this works as expected except that I cannot figure out how to correctly position the dialog. I would like it to display centered over the Outlook window. I know I have access to the Microsoft.Office.Interop.Outlook.Application.ActiveWindow()
, but I do not see how that helps me since I cannot translate it to a PlacementTarget
as expected in the settings for Caliburn.Micro WindowManager's ShowDialog method.
WPF User Control Library
namespace WpfUserControlLibrary {
public static class Connector {
public static void ShowDialog() {
new AppBootstrapper();
var windowManager = IoC.Get<IWindowManager>();
windowManager.ShowDialog( new ShellViewModel() );
}
}
}
Outlook 2010 Add-in
WpfUserControlLibrary.Connector.ShowDialog();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够找到解决方案。感谢这个问题的帮助,我能够将适当的父窗口位置和大小参数传递给连接器。我检查了 Caliburn.Micro 源代码,发现我实际上正在创建一个
ChildWindow
,而不是Popup
。因此,我只需要设置对话框设置的Top
和Left
值。WPF 用户控件库
Outlook 2010 加载项
I was able to track down a solution. Thanks to the help of this question, I was able to pass the appropriate parent window location and size parameters to the Connector. I checked the Caliburn.Micro source and noticed that I'm actually creating a
ChildWindow
--not aPopup
. Therefore, I just needed to set theTop
andLeft
values of the settings for the dialog.WPF User Control Library
Outlook 2010 Add-in