InvalidOperationException When Floating A Document Containing A CustomControl With Focus() In It's OnApplyTemplate()
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with LayoutFloatingWindowControl.OnActivated and the attached README and InvalidOperationException.txt. Reproduce the failure by floating a document containing a CustomControl whose OnApplyTemplate calls Focus(), then use the provided call stack to trace the message handling. Done means the document floats without the InvalidOperationException and existing floating behavior remains intact.
Written by the indexing model from the issue text.
Description
While looking to see if this issue was addressed, I feel like I've seen similar issues with focusing or using Keyboard.Focus(). However most of those caused a NullReferenceException.
I am getting an InvalidOperationException when I drag the tab of a document to cause it to float. It seems to occur when the document contains a CustomControl which calls Focus() within it's OnApplyTemplate() method.
It seems to happen because when focusing I think the Dispatcher suspends messages but LayoutFloatingWindowControl sends a message in its OnActivated method.
I was running a local copy of AvalonDock when I encountered it and I changed the code to:
Application.Current.Dispatcher.BeginInvoke(()=> Win32Helper.SendMessage( windowHandle, Win32Helper.WM_NCLBUTTONDOWN, new IntPtr( Win32Helper.HT_CAPTION ), lParam ));
and it works for my purposes so far, although I have no idea if there will be any side effects?
It is extremely simple to reproduce. Attached is a folder containing the solution, a README explaining basically what I said here, and a file called "InvalidOperationException.txt" containing the exception info and CallStack of the error.
AvalonDockError.zip
Also, I believe this is completely unrelated, but while looking into this issue, I found that Microsoft discourages the use of SendMessage without checking InSendMessage to avoid deadlocks. Messages are a little over my head though and again I believe this to be unrelated as I've tried this and InSendMessage returned false but the error still occurred.
- Dominant language
- C#
- Stars
- 4.2k
- Forks
- 912
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xceedsoftware/wpftoolkit
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
xceedsoftware/wpftoolkit#1808 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
xceedsoftware/wpftoolkit#1807 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
xceedsoftware/wpftoolkit#1806 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
xceedsoftware/wpftoolkit#1804 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
xceedsoftware/wpftoolkit#1802 · 3 comments ·
All issues in xceedsoftware/wpftoolkit
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·