These are chat archives for AvaloniaUI/Avalonia

2nd
Nov 2016
danwalmsley
@danwalmsley
Nov 02 2016 12:45
@grokys you about?
I'm getting an exception
I have a control inside a content control (inside a template)
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
        {
            Header = null;
            Content = null;
        }
header and content are the properties the ContentControls content are bound to
it crashes here when I close the item
Additional information: Was attached to logical tree but cannot find root.
(This worked before, but now these controls have DockNC in the way)
either it was wrong for me to set the content to null on DetachedFromVisualTree or there is a bug in dock nc
any suggestions?
Steven Kirk
@grokys
Nov 02 2016 12:53
yeah that is basically a logic error saying something is wrong with the state
danwalmsley
@danwalmsley
Nov 02 2016 12:54
did it seem ok to clear content of contentcontrol inside ondetached from visual tree?
Steven Kirk
@grokys
Nov 02 2016 12:56
is it that line that's causing the error?
i think that should be allowable but could be that it's not something that's been tested
danwalmsley
@danwalmsley
Nov 02 2016 12:56
yes, but only since I put DockNC in there... so I guess
bug is really that DockNC stops it from finding route at this stage...
that line was just to fix a memory leak
Steven Kirk
@grokys
Nov 02 2016 12:57
finding route?
danwalmsley
@danwalmsley
Nov 02 2016 12:57
and its probably not what really fixed it
man I need to go get some lunch
"root"
Steven Kirk
@grokys
Nov 02 2016 13:10
yeah actually thinking about it, it's probably not going to be a good idea to alter the visual tree in OnDetachedFromVisualTree
though if it is necessary I think we can probably make it work
danwalmsley
@danwalmsley
Nov 02 2016 13:56
is there some kind of OnDetachingFromVisualTree that gets called just before its detached?
Darnell Williams
@Seeker1437
Nov 02 2016 13:57
Basically the DockControl would normally create items in code, which would only have them in the visual tree, however for @danwalmsley for the moment the entire tree is defined in xaml, which has the items in the logical tree, and because it's a ContentControl, I'm curious if it should have a different base class or not.
Steven Kirk
@grokys
Nov 02 2016 14:01
Basically the DockControl would normally create items in code, which would only have them in the visual tree,
??!
it should make no difference if things are created in code or xaml
the logical tree exists outside of xaml
danwalmsley
@danwalmsley
Nov 02 2016 14:02
I'm glad you just said that!
Steven Kirk
@grokys
Nov 02 2016 14:02
is there some kind of OnDetachingFromVisualTree
no, because what would happen if you then detached a subtree in that event?
i don't think that would solve anything
danwalmsley
@danwalmsley
Nov 02 2016 14:03
I think the problem is in DockNC!
its broken the path to finding the root somehow
Steven Kirk
@grokys
Nov 02 2016 14:03
will each control should have a reference to its root
Darnell Williams
@Seeker1437
Nov 02 2016 14:04
When I have tested it I found that branches would only in the visual tree
Only appear
Steven Kirk
@grokys
Nov 02 2016 14:04
sounds like you're not setting up the logical tree properly
if i remember correctly you're not using Panel or Decorator or any of the controls that handle that bookkeeping for you
so you need to do that
i pointed you to the code that you need to use a couple of times already
danwalmsley
@danwalmsley
Nov 02 2016 14:06
@grokys so wrapping the content control in a panel ?
Steven Kirk
@grokys
Nov 02 2016 14:07
that's one solution i think
you need to do something like that if you want to write your own low level panel-type class
Darnell Williams
@Seeker1437
Nov 02 2016 14:11
Oh yes you're right I think i had a question that I never asked
danwalmsley
@danwalmsley
Nov 02 2016 14:12
@Seeker1437 I think we need to do that, on Branch, and DockControl?
both are essentially a type of panel
Darnell Williams
@Seeker1437
Nov 02 2016 14:12
See here is the issue
Branch is a control that is used by DockControl to do it's layout
So normally no one would ever have to actually touch Branch directly, it like a container

I wasn't sure how to set up the Child/Children changed logic based off that because it could continually nest.

I have something called BranchAccessor which can traverse the Branches to find content within the DockControl, but because this is not yet finished there is also another type which will actually map everything out.

I am willing to just try using something else, but I don't see anything that is really promising
danwalmsley
@danwalmsley
Nov 02 2016 14:17
@Seeker1437 your DockControl inherits contentcontrol
I think that could be part of the issue
I think you need to make it a template control
and the template has a content control inside it.
Darnell Williams
@Seeker1437
Nov 02 2016 14:19
Okay
This controls not finished, that's my only argument xD
danwalmsley
@danwalmsley
Nov 02 2016 14:20
oh I know ;) I just want to help you get it to work
Darnell Williams
@Seeker1437
Nov 02 2016 14:22
True xD
Can you imagine that branch is invisible?
a silent worker so to speak
there are supposed to be 4 parts to it that makes this such an awesome thing
the logical tree would be set up by the tabcontrol
danwalmsley
@danwalmsley
Nov 02 2016 14:27
@Seeker1437 iv made the same mistake in my texteditor control
that's true but you should be able to declare everything in XAML too!
AvalonDock you can!
Darnell Williams
@Seeker1437
Nov 02 2016 14:28
Well whatI mean its, that you would simple ly place tab items in a hierarchy and the branches would be laid out for you int he background
Ill just do it, talk is cheap xD
danwalmsley
@danwalmsley
Nov 02 2016 21:28
@grokys is this code unfinished...
I'm finding that if I have carousel control
and my texteditor is inside @Seeker1437s dock
then I end up with visual tree cut off at the panel child to Carousel presenter... like this
image.png
(that's showing visual ancestors following detach)
and this is visual ancestors before detach
image.png
so its stopped at carousel which I think might be due to that method not being completed, I can probably finish it, just need to check if that the likely cause of this issue
Steven Kirk
@grokys
Nov 02 2016 21:57
sorry can't check right now - having computer issues arrgh!
Steven Kirk
@grokys
Nov 02 2016 23:25
ok issues sorted
but i can't make any sense of your screenshots
Steven Kirk
@grokys
Nov 02 2016 23:34
on the first one there seems to be an extra windows taskbar and word or something?
and the second one is too small to see properly