Hi,
I have a XamDockManager, with some Tabbed Documents. Each ContentPane contains a UserControl. The problem I'm having is this; when one of my UserControls is the Active pane, and I try to open another ContentPane and call Activate, the new pane very briefly shows, but then the previous pane is reactivated.
What would cause a Tab to Activate on it's own? I'm only calling Activate in one place where I add a new ContentPane tabbed document.
Thanks
Andy
Activation is based around the input/keyboard focus of the wpf elements. The behavior you are describing sounds like focus is not shifting into the pane. I have seen two different scenarios that may lead to this. One is if the thing to receive focus was an HwndHost (including a Frame navigated to a web page, webbrowser, windowsformshost, addinhost, etc.). When an HwndHost receives focus it has to shift focus into its hwnd in which case there is no focusedelement (since focus is no longer within the wpf hwnd). This issue was reported recently and is addressed by the next hotfix. The other case is if the last element with focus within the pane was collapsed/hidden. In this case when the pane is activated it tries to focus the last focused element which in the case of a hidden/collapsed element ends up being a no-op so focus remained where it was. This too was reported recently and should be addressed in the next hotfix. In the interim, the second issue could be handled by explicitly focusing an element within the pane that is visible or possibly even the contentpane itself. In any case, you may want to submit the issue to the support group so you can be notified when the fix is available and to ensure that the scenario you are hitting is actually addressed by the fix.
I'm attempting to work around the second case that you've mentioned by checking to see if the element with logical focus in the newly active pane is visible. If not, I'll set logical focus to the ContentPane. I'm using the XamDockManager.ActivePaneChanged event to get the newly active pane. However, the NewValue property on the EventArgs is null when the element with logical focus is not visible.
I can set Focusable to 'false' on the element that becomes hidden, but this has some undeirable side effects. Do you know of any other way to work around this issue (until 9.1 is released)?
The untested hotfix I was able to obtain seems to resolve my issue.
The issue is addressed internally and will be part of the 9.1 release as well as addressed in the next hotfix for 8.1 & 8.2. With regards to a workaround, you may be able to just set FocusManager.IsFocusScope to false on the ContentPanes although I don't have the project to reproduce it available to ensure that will workaround it. You could also try to catch when the FocusedElement of the ContentPane is changed and hook the element's IsVisibleChanged and if it goes to false then change the active pane or possibly just clear the FocusedElement when the pane is no longer the active pane.
I don't know if this helps or not, but I was able to submit a project to demonstrate the problem, and they are working on a hotfix. It's been in the "Awating Testing" phase for quite some time now though.