ButchersBoy / Dragablz

Dragable and tearable tab control for WPF
http://dragablz.net
MIT License
2.2k stars 323 forks source link

Errors when tear off a tab inside a page #225

Closed ha-nso-li closed 4 years ago

ha-nso-li commented 5 years ago

It raises exceptions when I tear off a tab. 'TabablzControl' is in 'Page' control.

MainWindow.xaml

<Frame NavigationUIVisibility="Hidden" Grid.Row="0" Grid.Column="1" Content="{Binding MyPage}" />

And I set 'ImagePage' as 'MyPage' from view model.

ImagePage.xaml

<Grid>
    <dragablz:TabablzControl Margin="8">
        <dragablz:TabablzControl.InterTabController>
            <dragablz:InterTabController />
        </dragablz:TabablzControl.InterTabController>
        <TabItem Header="Tab No. 1" IsSelected="True">
            <TextBlock>Hello World</TextBlock>
        </TabItem>
        <TabItem Header="Tab No. 2">
            <TextBlock>We Have Tearable Tabs!</TextBlock>
        </TabItem>
    </dragablz:TabablzControl>
</Grid>

Exception (in Korean)

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=Background; DataItem=null; target element is 'TabablzControl' (Name=''); target property is 'Background' (type 'Brush')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Window', AncestorLevel='1''. BindingExpression:Path=(0); DataItem=null; target element is 'TabablzControl' (Name=''); target property is 'Foreground' (type 'Brush')
호출 대상이 예외를 Throw했습니다.
   위치: System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   위치: System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   위치: System.Delegate.DynamicInvokeImpl(Object[] args)
   위치: System.Windows.RoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   위치: System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   위치: System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   위치: System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   위치: System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   위치: System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   위치: Dragablz.DragablzItem.ThumbOnDragDelta(Object sender, DragDeltaEventArgs dragDeltaEventArgs) 파일 C:\projects\dragablz\Dragablz\DragablzItem.cs:줄 547
   위치: System.Windows.Controls.Primitives.DragDeltaEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   위치: System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   위치: System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   위치: System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   위치: System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   위치: System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   위치: System.Windows.Controls.Primitives.Thumb.OnMouseMove(MouseEventArgs e)
   위치: System.Windows.UIElement.OnMouseMoveThunk(Object sender, MouseEventArgs e)
   위치: System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   위치: System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   위치: System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   위치: System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   위치: System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   위치: System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   위치: System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   위치: System.Windows.Input.InputManager.ProcessStagingArea()
   위치: System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   위치: System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   위치: System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   위치: System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   위치: System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   위치: MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   위치: MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   위치: System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   위치: System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   위치: System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   위치: MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   위치: MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   위치: System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   위치: System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   위치: System.Windows.Application.RunDispatcher(Object ignore)
   위치: System.Windows.Application.RunInternal(Window window)
   위치: System.Windows.Application.Run(Window window)
   위치: System.Windows.Application.Run()
   위치: IVim.IVM.Viewer.App.Main()
Unable to ascertain tab control.
   위치: Dragablz.DefaultInterTabClient.GetNewHost(IInterTabClient interTabClient, Object partition, TabablzControl source) 파일 C:\projects\dragablz\Dragablz\DefaultInterTabClient.cs:줄 21
   위치: Dragablz.TabablzControl.MonitorBreach(DragablzDragDeltaEventArgs e) 파일 C:\projects\dragablz\Dragablz\TabablzControl.cs:줄 1244
   위치: Dragablz.TabablzControl.ItemDragDelta(Object sender, DragablzDragDeltaEventArgs e) 파일 C:\projects\dragablz\Dragablz\TabablzControl.cs:줄 1161
처리되지 않은 'System.Reflection.TargetInvocationException' 형식의 예외가 mscorlib.dll에서 발생했습니다.
호출 대상이 예외를 Throw했습니다.

It seems this problem is similar to #117 but it isn't.

App.xaml

<Style TargetType="{x:Type dragablz:TabablzControl}" BasedOn="{StaticResource MaterialDesignTabablzControlStyle}">
    <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Path=Background}" />
    <Setter Property="TextElement.Foreground" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Path=(TextElement.Foreground)}" />
</Style>

When I fix AncestorType from Window to Page, System.Windows.Data error is gone but an exception was still raised.

Enviroment: C# 4.7.2 Dragablz v0.0.3.203, MahApps.Metro v1.6.5, MaterialDesignThemes v2.5.1, Prism v7.10.431 etc.... All libraries are installed from NuGet.

ha-nso-li commented 5 years ago

Workaround: I temporary disabled tearable tab feature. (see #115)

ha-nso-li commented 4 years ago

Closing the issue that I'm not interested in anymore. + It seems the project is inactive and abandoned.