I just got done following the steps in this MSDN article on creating a WPF UI AddIn: http://msdn.microsoft.com/en-us/library/bb909849%28v=vs.90%29.aspx
The code works, clicking the button makes the box pop up, ectect. I placed the Add-in’s usercontrol in a tab item, as the Tab item’s content:
TabItem tab = new TabItem();
tab.Name = info.AssemblyName.Name;
tab.Header = info.Name;
tab.Content = plug.GetAddInUI();
TabHost.Items.Add(tab); //Add the page to the TabControl
This worked perfectly, as expected. However, an interesting thing happens when you click the button. The messagebox pops up, but then the tab control “freezes”. I can’t switch to any other tabs. The button still triggers the messagebox, and I can move the whole window, so the program isn’t hung.
I can “force” the tab control to fix itself by entering break mode via VS, then resuming the program, or by minimizing/restoring the window, ect.
I’ve read the posts about MessageBox inhibiting event processing, so I changed the Messagebox to a Debug.Writeline. The bug still persists.
My code follows MSDN’s almost to the letter, however, as it’s quite long, I’d refrain from posting all of it here. At the same time, I’m unsure which segments are relevant. If you tell me which parts to post, I”ll do so.
I managed to resolve it by calling TabControl.Focus() when the selection changed, like so:
I believe this is a bug in WPF, and not anything that I did.