ButchersBoy / Dragablz

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

applicationexception: unable to ascertain tab control. #233

Open kwatman opened 4 years ago

kwatman commented 4 years ago

so its my first time using this so i wanted to tet how it works. i copy patsed the sample code and when i run it it works. bu the moment i try to tear of the tab i get this error: applicationexception: unable to ascertain tab control.

System.Reflection.TargetInvocationException HResult=0x80131604 Message=Exception has been thrown by the target of an invocation. Source=mscorlib StackTrace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Delegate.DynamicInvokeImpl(Object[] args) at System.Windows.RoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at Dragablz.DragablzItem.ThumbOnDragDelta(Object sender, DragDeltaEventArgs dragDeltaEventArgs) at System.Windows.Controls.Primitives.DragDeltaEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.Controls.Primitives.Thumb.OnMouseMove(MouseEventArgs e) at System.Windows.UIElement.OnMouseMoveThunk(Object sender, MouseEventArgs e) at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at WorldCraft.App.Main() Inner Exception 1: ApplicationException: Unable to ascertain tab control.

this is the code of my xaml page: `<Page x:Class="WorldCraft.Pages.WorldEditor" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:WorldCraft.Pages" xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" Title="WorldEditor" DataContext="{Binding WorldEditorInstance, Source={StaticResource Locator}}">

<Grid>
    <!--row defenitions-->
    <Grid.RowDefinitions>
        <RowDefinition Height="6*" />
        <RowDefinition Height="90*" />
    </Grid.RowDefinitions>

    <!--toolbar-->
    <ToolBar>
        <Menu>
            <MenuItem Header="File">
                <MenuItem Header="New" Command="{Binding newWorld}"/>
                <MenuItem Header="Open" Command="{Binding openWorld}"/>
                <MenuItem Header="Save" Command="{Binding saveWorld}"/>
            </MenuItem>
        </Menu>
        <Menu>
            <MenuItem Header="Category">
                <MenuItem Header="add" Command="{Binding addCategory}"/>
                <MenuItem Header="create" Command="{Binding createCategory}"/>
            </MenuItem>
        </Menu>
    </ToolBar>

    <dragablz:TabablzControl Margin="8" Grid.Row="1">
        <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>

`

BornToBeRoot commented 3 years ago

@dolfijn3000 Did you solve this issue?

LegoCodr commented 3 years ago

I get same error in my project too, I'm using stylet mvvm framework, which suggested me to delete the code bihind file *.xaml.cs . But when I recreated this code behind file, the error dispeared, everything is ok now. There's nothing more than a "InitializeComponent()" in the file. And now the Dragablz works. Hope this can help you too.