Dirkster99 / AvalonDock

Our own development branch of the well known WPF document docking library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActiveContent not switching correctly for floating window

Muhahe opened this issue · comments

Hi,

i noticed another strange behavior, which can be easily reproduced in your MVVMTestApp.

In case you have atleast two documents (doc1, doc2) and some panel that displays content based on ActiveContent property of avalondock (FileStatsPanel).

Place doc1 as normal document
Place FileStatsPanel as side panel
Place doc2 as floating window

image

Then when you select doc1, FileStatsPanel displays data based on doc1 - ok
When you select doc2, FileStatsPanel displays data based on doc2 - ok

Steps

  1. select doc1
  2. select doc2
  3. select File Stats panel

If you make steps 1,2,3 then fileStatsPanel will display content based on doc1 instead of doc2. So editing FileStats data for doc2 isnt possible in this case

if ou make steps 1,2,3,2,3 then fileStatsPanel will display content correctly.

When FileStatsPanel is as floating panel, everything works fine.

In my opinion, issue is based on changing ActiveContent to document when clicking from floating window into non-floating panel, then ActiveContent is changed to document that is in same window as non-floating panel. (can be observed by breakpoint in workspace.cs -> ActiveDocument setter (line 109?)

MVVMTestApp.dll!AvalonDock.MVVMTestApp.Workspace.ActiveDocument.set(AvalonDock.MVVMTestApp.FileViewModel value) Line 109 C#
[External Code]
AvalonDock.dll!AvalonDock.DockingManager.ActiveContent.set(object value) Line 1027 C#
AvalonDock.dll!AvalonDock.DockingManager.OnLayoutRootPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) Line 1794 C#
AvalonDock.dll!AvalonDock.Layout.LayoutElement.RaisePropertyChanged(string propertyName) Line 128 C#
AvalonDock.dll!AvalonDock.Layout.LayoutRoot.InternalSetActiveContent(AvalonDock.Layout.LayoutContent currentValue, AvalonDock.Layout.LayoutContent newActiveContent) Line 750 C#
AvalonDock.dll!AvalonDock.Layout.LayoutRoot.ActiveContent.set(AvalonDock.Layout.LayoutContent value) Line 235 C#
AvalonDock.dll!AvalonDock.Layout.LayoutContent.IsActive.set(bool value) Line 183 C#
AvalonDock.dll!AvalonDock.Controls.LayoutDocumentControl.SetIsActive() Line 135 C#
AvalonDock.dll!AvalonDock.Controls.LayoutDocumentControl.OnPreviewGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e) Line 111 C#

I can verify the issue and extended the MVVMTestApp sample to make the issue more obvious.

I can place a line like:
Debug.WriteLine("OnPreviewGotKeyboardFocus: " + LayoutItem.ContentId);

into LayoutDocumentControl.OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
at line 110 to see that the document in the MainWindow receives the focus preview event.

I am not sure this is bug. To me this looks more like a WPF limitation because I don't know how to distinguish this event from the real event when the user clicks inside the document(?). Do you have an idea how to handle this differently?

I just cant figgure out why document is receiving focus when is not clicked. I expected, that properties panel should got focus not document

Yes I do not have more information ever - the event is being raised by WPF and I do not know exactly why in this manner...

Fixed in my pull request @Dirkster99

Looks good to me too :-)
@Muhahe Please let us know if you see anything we are missing here.