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)?
Hmm... I'm not sure either of these is the case. I'm using Wpf controls only, and there should be something visible on the UserControl being displayed in the new pane. How can I confirm this?
This was all working before... I'm not sure what is causing this behavior, but it seems I can ONLY replicate it if the new pane is being created in response to a RoutedEvent raised by the UserControl which ends up "stealing" the focus back.
Any ideas?