These are chat archives for AvaloniaUI/Avalonia

7th
Nov 2016
danwalmsley
@danwalmsley
Nov 07 2016 10:10
@grokys you around, just need a couple of pointers to help me fix carousel
Steven Kirk
@grokys
Nov 07 2016 10:57
i am now!
danwalmsley
@danwalmsley
Nov 07 2016 10:58
hey !
ok I might be wrong, but im suspecting carousel is breaking visual tree
remember those terrible screenshots I posted
iv pasted the data into #798
showing my controls logical and visual ancestors when onattached and on detached from visual tree gets called
since moving to DockNC control, I get an exception that it cant find root!
the 2 examples I have posted, the first 1 works
Steven Kirk
@grokys
Nov 07 2016 11:00
so you're modifying the visual tree in the OnAttachedToVisualTree and OnDetachedFromVisualTree?
danwalmsley
@danwalmsley
Nov 07 2016 11:00
but the second it doesn't... however in both cases the tree seems cut off at the carousel leve
just ondetached from visual tree!
probably a bad idea!
Steven Kirk
@grokys
Nov 07 2016 11:00
yeah i think we need to make that throw an exception
danwalmsley
@danwalmsley
Nov 07 2016 11:00
ok sure
my texteditor control
Steven Kirk
@grokys
Nov 07 2016 11:01
i'd need to look into it further but i think it's a bad idea (ignore me saying it shouldn't be a problem earlier - i had time to think about it!)
danwalmsley
@danwalmsley
Nov 07 2016 11:01
has a Content property and a Header property
that allows text editor to be extended
im trying to have them removed when the editor gets detached
so maybe I just needed to make them logical childrenb
and avalonia would have sorted it for me?
Steven Kirk
@grokys
Nov 07 2016 11:05
why do you need to remove them when detaching from the visual tree?
danwalmsley
@danwalmsley
Nov 07 2016 11:06
i was getting a memory leak!
without it
let me post what the tree actually looks like
danwalmsley
@danwalmsley
Nov 07 2016 11:11
image.png
so the content presenter highlighted there contains my texteditor
but I cant see its logical children, so it looks like Carousel is breaking logical tree?
or would that be expected?
Steven Kirk
@grokys
Nov 07 2016 11:16
right, the ContentPresenter when its inside the control template doesn't add the control to the logical tree
because the logical tree is the stuff you see outside the control template
so yeah that looks wrong
danwalmsley
@danwalmsley
Nov 07 2016 11:17
ok
so that looks as though the Carousel should have manually added to logical tree?
a bit like what @Seeker1437 had to do other day on his dock?
Steven Kirk
@grokys
Nov 07 2016 11:18
so the ContentPresenters shouldn't be the logical children of the carousel, instead the ContentPresenter.Children should be
danwalmsley
@danwalmsley
Nov 07 2016 11:18
ok and I can probably fix this, by grabbing the ContentPresenter in the ontemplate applied
and add ContentPresenter.Child to logical tree?
i think that's really old code and things have changed since then
danwalmsley
@danwalmsley
Nov 07 2016 11:20
ok right I will try and submit a pr to correct this. ;)
Steven Kirk
@grokys
Nov 07 2016 11:20
sorry there seems to be a delay
@danwalmsley
ok and I can probably fix this, by grabbing the ContentPresenter in the ontemplate applied
and add ContentPresenter.Child to logical tree?
yeah that sounds right
danwalmsley
@danwalmsley
Nov 07 2016 11:20
thanks you clarified things
Steven Kirk
@grokys
Nov 07 2016 11:20
the test i linked to above should be testing for TextBlock as the logical child
danwalmsley
@danwalmsley
Nov 07 2016 11:20
ok
oh quick question
so carousel its logical children should be all the items or just the selected item?
Steven Kirk
@grokys
Nov 07 2016 11:28
yeah this is a difficult question...
danwalmsley
@danwalmsley
Nov 07 2016 11:28
my gut feeling is that it would contain all the items
Steven Kirk
@grokys
Nov 07 2016 11:28
it should probably be:
  1. when not virtualized all items should be logical children
  2. when virtualized all items that are controls should be logical children plus the current selection
because if you add say a string as an item and the carousel is virtualized, you can't make that a logical child until its materialized by the ContentPresenter
or maybe for 2. it should only ever be the current selection... not sure
this causes pain in all the ItemsControls :/
maybe we should just say that "logical children are the materialized items"
and move away from the WPF way of thinking
Steven Kirk
@grokys
Nov 07 2016 11:33
as we can't have non-control logical children as WPF can, because that makes no sense for styling for us
danwalmsley
@danwalmsley
Nov 07 2016 11:34
sounds like it would be simpler
ok I will push the failing unit test...
im struggling to find how it currently sets the content presenter as its logical child though
iv stepped through, it seems that gets done by default by the base class
Steven Kirk
@grokys
Nov 07 2016 11:42
which base class?
danwalmsley
@danwalmsley
Nov 07 2016 11:42
just stepping through again...
2 secs
Darnell Williams
@Seeker1437
Nov 07 2016 11:43
yeah @danwalmsley i used the ContentPresenter.Child to fix the logical tree in branch
Carousel uses a panel right?
danwalmsley
@danwalmsley
Nov 07 2016 11:46
yes!
Darnell Williams
@Seeker1437
Nov 07 2016 11:47
if it has children, check out Branch, some rough logical management code in there
this is where I think it maybe setting the logical child to contentpresenter?
Darnell Williams
@Seeker1437
Nov 07 2016 11:52
its possible :O
maybe add a check if it inherits IPresenter and grab the child insteqd recursively?
Steven Kirk
@grokys
Nov 07 2016 11:53
no, that's just adding the child to the panel
Darnell Williams
@Seeker1437
Nov 07 2016 11:53
oh
Steven Kirk
@grokys
Nov 07 2016 11:54
i think this might actually be a bug in ItemsControl...
Darnell Williams
@Seeker1437
Nov 07 2016 11:54
that reminds me @grokys is it possible to tell the ItemContainsrGenerater to generate containers of a specified type?
Steven Kirk
@grokys
Nov 07 2016 11:55
part of the problem is i've not quite decided how the logical tree should work! ;)
Darnell Williams
@Seeker1437
Nov 07 2016 11:57
Can the containers be modified through events?
like PrepareContainerForItem?
I need to be able to do some magic to the containers before they are returned by the generater
Steven Kirk
@grokys
Nov 07 2016 11:58
probably
Darnell Williams
@Seeker1437
Nov 07 2016 12:00
I was looking, and I saw we dont have the aboloty to effect it like that right off hand, I tried to add it myself but I did something wrong because I dont quite understand how the generater works at each stage xD
Steven Kirk
@grokys
Nov 07 2016 12:01
@danwalmsley so i think i'm starting to remember how this ended up being as it is
when you have a typed item container generator, obviously the logical children are the typed items, e.g. ListBox
danwalmsley
@danwalmsley
Nov 07 2016 12:02
ok
Darnell Williams
@Seeker1437
Nov 07 2016 12:02
oh right 1hr before training starts! Ill continue later @grokys
Steven Kirk
@grokys
Nov 07 2016 12:03
when you don't have a typed item container generator, the items are created as ContentPresenters
but... ContentPresenters by default don't set the logical child
as usually the logical child will need to be applied to e.g. the ContentControl that contains the presenter
so - we need to decide if this is correct, and we should just make sure that the logical child is set in the presenter
or whether we need to select the Child of the ContentPresenter as the logical child in the ItemsControl
does that make sense?
danwalmsley
@danwalmsley
Nov 07 2016 12:06
yes,
im trying to think which way might be better
Steven Kirk
@grokys
Nov 07 2016 12:07
me too. i think probably the second option...
danwalmsley
@danwalmsley
Nov 07 2016 12:07
yes that sounds the obvious one...
so on the test you pointed out
let me quickly run it again before i say something completely wrong!
my pc is really slowww! so when I said quickly run it...
ok right
danwalmsley
@danwalmsley
Nov 07 2016 12:12
on that test, where we except textblock, but currently get contentpresenter
ContentPresenter.Child = null
and ContentPresenter.Content="Foo" (a string)
so at the moment that test isn't materializing into textblock
Steven Kirk
@grokys
Nov 07 2016 12:24
right, this is the old UpdateChild problem again
i really wish i'd not done it like that! need to fix it
Darnell Williams
@Seeker1437
Nov 07 2016 22:33
ah yeah :(
Darnell Williams
@Seeker1437
Nov 07 2016 22:57
Isnt that a simple fix? (I could be mistaken ofc)