Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange behavior when showing WPF window in Outlook
    primarykey
    data
    text
    <p>I use the following code to show my WPF window from the new message window in Outlook:</p> <pre><code>private void DisplayWindow(Window window) { var wih = new System.Windows.Interop.WindowInteropHelper(window); wih.Owner = GetForegroundWindow(); window.ShowInTaskbar = false; window.ShowDialog(); } [DllImport("user32.dll")] private static extern IntPtr GetForegroundWindow(); </code></pre> <p>My problem is that when ToolTips and ComboBox drop downs become visible, the WPF window disappears behind the new message window, leaving just the "popup" content in front. Could anyone explain why this might be happening, and what the correct way to host the window might be?</p> <p>EDIT:</p> <p>This only happens once a recipient has been added to the Send box and seems to only be a problem when the foreground window is the new mail message window.</p> <p>To replicate:</p> <p>Add an Outlook Add-in project and a WPF project (targeting .NET 4.0) to a new solution.</p> <p>Put a ComboBox with a few items in it on the MainWindow.xaml.</p> <p>Remove the <code>StartupUri</code> from App.xaml and add the following to App.cs.</p> <pre><code>public void ShowWindow() { MainWindow window = new MainWindow(); var wih = new System.Windows.Interop.WindowInteropHelper(window); wih.Owner = GetForegroundWindow(); window.ShowInTaskbar = false; window.ShowDialog(); } [DllImport("user32.dll")] private static extern IntPtr GetForegroundWindow(); </code></pre> <p>Add references to <code>WindowsBase</code>, <code>System.Xaml</code> and <code>PresentationFramework</code> to the Outlook project.</p> <p>Add a Ribbon (XML) to the Outlook project with the following in the .xml.</p> <pre><code>&lt;customUI ...&gt; &lt;ribbon&gt; &lt;tabs&gt; &lt;tab idMso="TabNewMailMessage"&gt; &lt;group id="MyGroup" insertAfterMso="GroupMailNew"&gt; &lt;button id="myButton" size="large" onAction="myButton_Action" imageMso="HappyFace"/&gt; &lt;/group&gt; &lt;/tab&gt; &lt;/tabs&gt; &lt;/ribbon&gt; &lt;/customUI&gt; </code></pre> <p>Add the following to the ribbon code.</p> <pre><code>MyWpfApplication.App app; public void Ribbon_Load(Office.IRibbonUI ribbonUI) { this.ribbon = ribbonUI; var appThread = new Thread(new ThreadStart(() =&gt; { this.app = new MyWpfApplication.App(); app.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown; app.Run(); })); appThread.SetApartmentState(ApartmentState.STA); appThread.Start(); } public void myButton_Action(Office.IRibbonControl control) { // Dispatcher used as cross thread operation. app.Dispatcher.BeginInvoke((Action)(() =&gt; { app.ShowWindow(); })); } </code></pre> <p>Add the following to ThisAddIn</p> <pre><code>protected override Microsoft.Office.Core .IRibbonExtensibility CreateRibbonExtensibilityObject() { return new Ribbon(); } </code></pre> <p>Run the Outlook add-in, create a new message, <strong>add a recipient</strong> and click on the smiley face button. You will see the bug when you click on the <code>ComboBox</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload