Reputation: 3012
I've been trying to figure out the correct way to pop up a dialog box in a way similar to MessageBox.Show in my VSTO addin. I read this could be achieved using WPF, but is there a better way? I've found many different examples most of which are in VBA, but I'm using C# so I'm having trouble translating them over. If someone could provide me with an example of popping up a dialog box in the addin in order to collect some information from the user, and point me towards the correct docs to tweak the settings of the dialog box it would help a lot. I can't seem to get it to work in C# using the VBA examples and as for the docs I can't find ones pertaining to dialog boxes in VSTO, just outside of it in WPF which I am not sure is possible to use in this situation.
Any assistance would be most appreicated. I just want to display a dialog box, and collect some info and that's it. I know of dialog launcher for VSTO ribbon groups, but that is not what I need.
Thanks in advance.
Upvotes: 1
Views: 3528
Reputation: 49395
You can use a regular System.Windows.Forms.Form instance to display a dialog window for collecting the required information. Use ShowDialog method which shows the form as a modal dialog box with the specified owner. Don't forget to psecify the parent window handle to prevent any changes in Outlook. The IWin32Window interface provides an interface to expose Win32 HWND handles to the ShowDialog method.
If you need to diaplay a WPF contant you may use the ElementHost class. This is a Windows Forms control that can be used to host a Windows Presentation Foundation (WPF) element.
Upvotes: 3