There are known problems between WPF and Office, but there should be some ways to work around them.
Can you explain a few things first?
Here are some suggestions from Codex:
This is a known focus/message-routing problem when showing a modeless WPF window from Excel. The WPF textbox can appear focused, but Excel is still receiving the keyboard messages, so typing and Ctrl+V go to the active cell.
The best solution is to host the UI in an Excel Custom Task Pane. If the UI is WPF, host the WPF UserControl inside a WinForms UserControl using ElementHost, and create that WinForms control as the Excel-DNA custom task pane.
If you must use a standalone modeless WPF window with Show(), try setting Excel as the owner window and enabling WPF modeless keyboard interop before calling Show():
var window = new MyWpfWindow();
new WindowInteropHelper(window)
{
Owner = ExcelDnaUtil.WindowHandle
};
ElementHost.EnableModelessKeyboardInterop(window);
window.Show();
window.Activate();
Add references to WindowsFormsIntegration, and use:
using System.Windows.Forms.Integration;
using System.Windows.Interop;
using ExcelDna.Integration;
ShowDialog() works because it creates a modal interaction with Excel, but that is not suitable if the user must continue working in Excel. For modeless UI, Custom Task Pane is the most robust approach.
If you’re still stuck after trying this, write back with a bit more details and I can try to make an example where the keyboard focus works right.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/exceldna/CH2PR05MB6887662FC37C18DC534A6C05F5022%40CH2PR05MB6887.namprd05.prod.outlook.com.