Git Product home page Git Product logo

Comments (19)

ButchersBoy avatar ButchersBoy commented on July 3, 2024

Can you send me a demo project?

from dragablz.

b-barry avatar b-barry commented on July 3, 2024

Hello,

Thanks you for your quick answer.

I have just created a demo project that you can find here:
https://github.com/b-barry/MahAppsDragablz/tree/dev/demo-project

I think that my error comes from InterTabClient. I don't implement my custom because I thought that the basic would be enough.

Thanks you for your helps:

Best regards

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

Ok. I'm away for a few days so I'll have a look next week.

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

OK, had a look at your code. Your setup has highlighted a "shortfall" in the DefaultInterTabClient. Dragablz is expecting the TabablzControl to be immediately there when the new Window loads. But in your case it is not, because it resides inside your main ContentControl and data binding has not yet completed, and thus the content has not yet been created...so no TabablzControl is ready.

I can fix this by getting the DefaultInterTabClient to wait for the initial databinding pass before it tries to find the TabablzControl. I think this is reasonable, as that class is designed to get people up and running out of the box quickly. For more advanced scenarios a custom version can always be provided.

I've just checked in the fix, so look out for the next build and let me know if it's working for you.

from dragablz.

b-barry avatar b-barry commented on July 3, 2024

Hello,

Thank you for your quick response and your search.
I kept searching on my side. I tried to create a custom InterTabClient to create a new host with a template Windows like in your sample. However, it did not succeed .
I still got the same exception.
From this, it occurred to me one question:
is it possible to release a tab, create a new host windows that do not possess a TabControl in its xaml ie set to null the 2nd parameter constructor newhost?
After go out, would be possible to put again this tab in its initial view ?

Best regards

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

No, the INewTabHost must be correctly populated with the tab control; Dragablz will validate this and if its not, will throw an error. It's quite a fundamental requirement that it can get the Tab control straight away.

But, if you update Dragablz from nuget in your demo project (https://github.com/b-barry/MahAppsDragablz/tree/dev/demo-project), you will see your original issue is fixed:

dragablz-issue17-fix

As stated above, the DefaultInterTabClient will no wait for the initial data bind which will give your TabControl chance to be loaded.

from dragablz.

b-barry avatar b-barry commented on July 3, 2024

Hello,

Thank you very much for your work.
I will update my project as soon.
I understand the fundamental requirement, it is important.
A latest question, if I use a newhost that creates the new tab into dragablz Windows, I will be able to put again this tab in its initial view ?

Thank you

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

Yeah you should be able to...you can intercept at that point so you can put the tab in whatever state you like...so long as it exists.

from dragablz.

BorisPetelj avatar BorisPetelj commented on July 3, 2024

Hello,

First I must say, the framework is great. It's just the thing I needed on project.

I ran into almost the same problem as @b-barry. When trying to drag out the tab, exception (Unable to ascrtain tab control.) is thrown.

The difference is that i use Pages whose Content and DataContext are set as appropriate properties on window itself for the purpose of navigation. One such Page contains TabablzControl with InterTabController and Tabs.
The page is first displayed as expected but mentioned exception is thrown on dragging the tab out.

The thing is, when I downloaded your demo project (above showing working gif), the same exception is thrown. Current Dragablz version in my project is 0.0.3.171, but nevertheless, demo project has 0.0.1.107 and not working on my machine.

Can you point me in the right direction? @b-barry never confirmed that the issue is fixed with newer Dragablz version.

Thank You for providing such great support!
Best regards, Boris.

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

Hi,the demo might be out of date, but this is still likely a problem in your app setup. If you post a sample GitHub repo I will try and take a look.

from dragablz.

BorisPetelj avatar BorisPetelj commented on July 3, 2024

This is the demo project.
https://github.com/BorisPetelj/DragablzDemo

Thank you for your time.

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

If you read the inner exception:

{"Unable to ascertain tab control."}

When your new Window is created, the tab control is not created.

From Dragablz perspective, when w tab is torn out, and new Window must be created, with a tab control immediately accessible, so the mouse can be recaptured and the users dragging motion can be completed.

It looks like you are only using your "Switcher" on app start up. You might want to consider implementing a custom "IInterTabClient" which will generated the new Window and get the tab control ready.

from dragablz.

BorisPetelj avatar BorisPetelj commented on July 3, 2024

I understand.
I implemented the "IInterTabClient", which is called when tearing out a tab. It creates new dragablz window (my custom one) with tab control and it's working fine. However, I have the following issue:

  • When tab is torn out, new template window is created with IInterTabClient support.
  • When this tab is restored back to original window in split mode, everything is ok.
  • Then, when trying to tear out the same tab again (from split mode), IInterTabClient is not called thus original window is created instead of my custom template window for teared tab. Since the original window does not have tab control (first issue) the "Unable to ascertain tab control." is thrown.

Note that if you restore tab back to original window (aside other tabs), you can tear it again with no exception.

If I move tab control to window from page, exception is not thrown but orginal (main) window is created, which I want to avoid.

I tried to investigate provided examples and found out about "dockablz:Layout.BranchTemplate" which is used for creating new tab control when tab is restored in split mode.
I used this component in my custom template window, also with IInterTabClient, which I hoped to solve the issue, but it keeps creating the original window (and thus throwing mentioned exception) when tearing tab the second time.

I updated demo project (link above), so if you can take a look I would greatly appreciate.

Also, is there a way to consolidate tabs that are created with IInterTabClient back to original window when closed?

Thank you for support, Boris.

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

ConsolidateOrphanedItems

from dragablz.

Maradaehne avatar Maradaehne commented on July 3, 2024

Hi,
I got a similiar error but a step later.

  • When tab is torn out, new template window is created with IInterTabClient support.

  • When this tab is restored back to original window in split mode, everything is ok.

  • I put the tab back from split mode to original tabcontrol, everything is ok

  • When i try to tear the same tab out again a target of invocation Exception is thrown

Message: Exception has been thrown by the target of an invocation.
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) in C:\projects\dragablz\Dragablz\DragablzItem.cs:line 547
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)

InnerException:

Message:

No parameterless constructor defined for this object.
Stacktrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Dragablz.DefaultInterTabClient.GetNewHost(IInterTabClient interTabClient, Object partition, TabablzControl source) in C:\projects\dragablz\Dragablz\DefaultInterTabClient.cs:line 14
at Dragablz.TabablzControl.MonitorBreach(DragablzDragDeltaEventArgs e) in C:\projects\dragablz\Dragablz\TabablzControl.cs:line 1195
at Dragablz.TabablzControl.ItemDragDelta(Object sender, DragablzDragDeltaEventArgs e) in C:\projects\dragablz\Dragablz\TabablzControl.cs:line 1112

Why is the first tearing out successfull, but the second is failing? It seems that dragablz is ignoring the custom tabclient.

Thanks in advance

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

Be very wary of your bindings Use Snoop first to check that InterTabController is setup as you expected.

from dragablz.

Maradaehne avatar Maradaehne commented on July 3, 2024

I tried to put it in a smaller project to reproduce the mistake and check it with snoop.

Unfortunately I am failing a step earlier now. This means, I can tear out the tab and restore it back to the original window in split mode, everything is ok. But when I want to tear out the same tab again the exception is thrown.

I checked with snoop and the Intertab Controller is set to the DefaultInterTabClient after the tab was restored in split mode in the original window, but it should be my custom tabclient. There is something that i am missing. If you could have look to it and give me a hint what i am missing I would be really grateful.

https://github.com/Maradaehne/DragablzIssue

from dragablz.

Maradaehne avatar Maradaehne commented on July 3, 2024

I found a way to get it work, but is it the intended way to set the IntertabController in this way:

    public INewTabHost<Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
    {
        var view = new TableMovementTabWindow();
        var model = new TableMovementTabViewModel(interTabClient, partition);
        view.DataContext = model;
        view.TabsContainer.InterTabController.InterTabClient = source.InterTabController.InterTabClient;
        return new NewTabHost<Window>(view, view.TabsContainer);
    }

from dragablz.

ButchersBoy avatar ButchersBoy commented on July 3, 2024

That's fine, you can set it however your want.

from dragablz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.