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();
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 theTopandLeftvalues of the settings for the dialog.WPF User Control Library
Outlook 2010 Add-in