sskodje / wpfchrometabs-mvvm

A tab control based on WPF chrome tabs, modified to work with the MVVM pattern
MIT License
256 stars 60 forks source link

Grabbing a window throws exception when its the only tab #1

Closed vepukki closed 9 years ago

vepukki commented 9 years ago

A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll The program '[5796] Demo.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

This exception is thrown when there are two tabs open and you drag the other one to new window and then close the remaining tab and drag the window back to the TabControl (to grab it as a tab again).

vepukki commented 9 years ago

System.InvalidOperationException was unhandled by user code HResult=-2146233079 Message=Can only call DragMove when primary mouse button is down. Source=PresentationFramework StackTrace: at System.Windows.Window.DragMove() at ChromeTabs.ChromeTabPanel.StartTabDrag(Point p, ChromeTabItem tab, Boolean isTabGrab) at ChromeTabs.ChromeTabPanel.StartTabDrag(ChromeTabItem tab, Boolean isTabGrab) at ChromeTabs.ChromeTabControl.GrabTab(Object viewModel)

This was the cause and when I catch this exception in my application then it works:

try { this.MyTabControl.GrabTab(dockedWindowVM); } catch(InvalidOperationException except) { Debug.WriteLine("Grabbing failed"); // do nothing }

sskodje commented 9 years ago

I reopened this, because it really is a bug :) What happens is a combination of having "drag window with one tab" enabled, and dragging in a window to an empty tab bar. Then it tries to drag the window, but the user does not have the primary mouse button down on the window, hence the exception.

I will upload a fix later today, and thank you very much for notifying me.

vepukki commented 9 years ago

In my case I didn't have the DragWindowWithOneTab="True" set on my tab control, but I it still gave the exception.

sskodje commented 9 years ago

Alright, the issue should be fixed now. Closing this.