These are chat archives for AvaloniaUI/Avalonia

4th
Nov 2016
Darnell Williams
@Seeker1437
Nov 04 2016 00:15

@grokys @jkoritzinsky @wieslawsoltes hey guys I am having a bit of a dilemma.

I have code that is trying to manage the visibility of BranchItems in my Branch.

@danwalmsley helped me with writing some code to accomplish some of this but the issue I am currently having is that our code does not work if I am assigning something to the value of a property when the property was originally null.

We opted to subscribe to the Changed event however I have learned Changed is called before binding is taking place making what I was expecting to be available not so available, is there something I can do to try and work around this?

Corrected some of the question!
This same problem would occur actually now that I have tested whenever the value of either property ever changes to a different object then what was previously there.
Oh right what might help is code!
Darnell Williams
@Seeker1437
Nov 04 2016 00:23

This is what we use to try and detect changes that have occurred as a result of the property changing:
https://github.com/Mabiavalon/DockNC/blob/master/src/Mabiavalon.DockNC/Docking/Branch.cs#L44

This is the code we use to try apply the IsVisible changes:
https://github.com/Mabiavalon/DockNC/blob/master/src/Mabiavalon.DockNC/Docking/Branch.cs#L168

at first it seems like it's working but in actuality it is buggy for some reason.

Steven Kirk
@grokys
Nov 04 2016 09:06
sorry @Seeker1437 i can't really understand your problem
it is buggy for some reason.
i need more info than that to help
I have learned Changed is called before binding is taking place making what I was expecting to be available not so available
you could ignore null values maybe?
code does not work if I am assigning something to the value of a property when the property was originally null
you need to be more specific than "does not work"
Darnell Williams
@Seeker1437
Nov 04 2016 10:30

@grokys you are right sorry, I attempted to explain "does not work"

with https://gitter.im/AvaloniaUI/Avalonia?at=581bd4e40d42ea911cbdf6a0

i need more info than that to help

Basically, the ContentPresenter Binds to the CLR Property to get it's child, therefor, when the Changed event is fired, even after calling UpdateChild I then realized that the ContentPresenter is not actually being updated until the CLR property is set and Changed is called before this happens!

Steven Kirk
@grokys
Nov 04 2016 12:02
sorry, i still don't understand :( could you try to at least correct your question so it makes grammatical sense in english? :P
danwalmsley
@danwalmsley
Nov 04 2016 12:02
@Seeker1437 I can take a look with you later on ;P
hehehe1
Steven Kirk
@grokys
Nov 04 2016 12:02
not trying to be a pain in the butt - i just don't understand what you're even asking!
Darnell Williams
@Seeker1437
Nov 04 2016 12:28
@grokys we are trying to making our control listen to and react to changes to the visibility in it's children.
Darnell Williams
@Seeker1437
Nov 04 2016 12:35
On a PC now I'll try to explain
SO basically, the control is Branch xD

Branch has two Content properties

FirstItem and SecondItem

In the style we have a ContentPresenter (named FirstContentPresenter) that is bound to FirstItem in Branch.
We subscribed to FirstItemProperty.Changed and within that, we get an Observable for IsVisible on whatever object is set to FirstContentPresenter.Child
Darnell Williams
@Seeker1437
Nov 04 2016 12:41
This issue that I have noticed is that FirstItemProperty.Changed is called before FirstItem.set.
That is an issue because we previously assumed that FirstItemProperty.Changed would allow us to gain access to the most up to date value for FirstContentPresenter.Child but this is incorrect because it has not actually be set at that point.
danwalmsley
@danwalmsley
Nov 04 2016 12:45
@Seeker1437 FirstItemProperty.Changed takes an arguent of AvaloniaPropertyChangedEventArgs (or similar name)
and that class has properties
e.OldValue
and e.NewValue
so you should be able to see both
the old and the new... just grabbing something to eat will come take a look, you on teamviewer today?
Darnell Williams
@Seeker1437
Nov 04 2016 12:46
yes, but the issue is that the ContentPresenter is bound to the CLR property
the CLR property FirstItem is not updated with the new value until after FirstItemProperty.Changed
and remember FirstContentPresenter is bound to FirstItem this means that any code that tries to access FirstContentPresenter during Changed is accessing too early
Steven Kirk
@grokys
Nov 04 2016 12:54
i think your problem is that FirstItemProperty.Changed will trigger whenever the property is changed on any FirstItem - not only the one on the current instance
Darnell Williams
@Seeker1437
Nov 04 2016 12:57
Ill give it a shot :O
Steven Kirk
@grokys
Nov 04 2016 12:58
i think so - either that or check that o.Sender == this in the handler
think about it: FirstItemProperty.Changed is a static property
Darnell Williams
@Seeker1437
Nov 04 2016 12:59
ooh you're so right....
I forgot about that... XD
But the issue is that it's happening, just within one instance of Branch
Steven Kirk
@grokys
Nov 04 2016 13:00
in your handler is o.Sender == this?
Darnell Williams
@Seeker1437
Nov 04 2016 13:01
not currently
I just added it and am testing
Yes, and it still is occuring
Steven Kirk
@grokys
Nov 04 2016 13:02
in the handler what are the values for o.OldValue and o.NewValue?
Darnell Williams
@Seeker1437
Nov 04 2016 13:03
o.OldValue = null
o.NewValue = [Avalonia.Controls.Button]
Steven Kirk
@grokys
Nov 04 2016 13:04
ok, and at that point what is the value of this.FirstItem? (assuming you're in the FirstItemProperty.Changed handler)
Darnell Williams
@Seeker1437
Nov 04 2016 13:04
null
Steven Kirk
@grokys
Nov 04 2016 13:04
thats.... impossible very strange
what are the values for o.Sender.GetHashCode() and this.GetHashCode()?
Darnell Williams
@Seeker1437
Nov 04 2016 13:05
wait!
sorry I read the wrong property, it's the button
Steven Kirk
@grokys
Nov 04 2016 13:06
so the property is set
is your problem solved?
Darnell Williams
@Seeker1437
Nov 04 2016 13:06
no, the ContentPresenter.Child is still null
Steven Kirk
@grokys
Nov 04 2016 13:07
what is ContentPresenter.Content?
Darnell Williams
@Seeker1437
Nov 04 2016 13:07
null
Steven Kirk
@grokys
Nov 04 2016 13:08
ok, so the change to FirstItem isn't getting passed to ContentPresenter
Darnell Williams
@Seeker1437
Nov 04 2016 13:08
right, it's supposed to happen via Binding
<ContentPresenter Name="PART_FirstContentPresenter" Content="{TemplateBinding FirstItem}"/>
Steven Kirk
@grokys
Nov 04 2016 13:10
do you have logging enabled? are there any binding errors in the VS output window?
Darnell Williams
@Seeker1437
Nov 04 2016 13:10
ill try enabling the logging I forget what the setting should be for that
we really need to make that an AppBuilder extension method, but PCLs make that very difficult :(
Darnell Williams
@Seeker1437
Nov 04 2016 13:15
Okay no warning or errors
Steven Kirk
@grokys
Nov 04 2016 13:16
try changing MinimumLevel.Warning to something lower like MinimumLevel.Debug
just to make sure logging is working
Darnell Williams
@Seeker1437
Nov 04 2016 13:18
DockTestApplication.vshost.exe Information: 0 : Layout: Started layout pass. To measure: 0 To arrange: 0
DockTestApplication.vshost.exe Information: 0 : Layout: Layout pass finised in 00:00:00.0000034
The thread 0x7358 has exited with code 0 (0x0).
DockTestApplication.vshost.exe Information: 0 : Layout: Started layout pass. To measure: 1 To arrange: 1
DockTestApplication.vshost.exe Information: 0 : Layout: Layout pass finised in 00:00:00.1365090
DockTestApplication.vshost.exe Information: 0 : Layout: Started layout pass. To measure: 7 To arrange: 7
DockTestApplication.vshost.exe Information: 0 : Layout: Layout pass finised in 00:00:00.0058594
Steven Kirk
@grokys
Nov 04 2016 13:18
ok, so logging is working, hmm
Darnell Williams
@Seeker1437
Nov 04 2016 13:19
I just think that maybe the binding is slow or we are accessing too early maybe
However if ContentPresenter was passed the new value before we get to Changed everything would function perfectly.
Steven Kirk
@grokys
Nov 04 2016 13:21
hmm yeah actually could be that the content presenter is getting the notification after your handler
why not subscribe to ContentPresenter.Child instead?
Darnell Williams
@Seeker1437
Nov 04 2016 13:23
This is actually what was causing the NaN thing I pm'd you about before because when we check for the value if it's null to the handler then IsVisible becomes false, so it ends up hiding the entire branch by setting IsVisible to false
I can try that :O
Steven Kirk
@grokys
Nov 04 2016 13:23
that's how ContentControl etc does it
Darnell Williams
@Seeker1437
Nov 04 2016 13:23
oh, I wish i thought to look there xD
Darnell Williams
@Seeker1437
Nov 04 2016 13:30
That seems so promising just made the changes, I'm going to test it :D
danwalmsley
@danwalmsley
Nov 04 2016 13:30
:)
Darnell Williams
@Seeker1437
Nov 04 2016 13:37
That was it
omg
it works properly now :D
danwalmsley
@danwalmsley
Nov 04 2016 13:38
awesome!!!
@Seeker1437 LGTM so I can try with AvalonStudio ;)
Darnell Williams
@Seeker1437
Nov 04 2016 13:38
@grokys @danwalmsley I could kiss you both right now!
danwalmsley
@danwalmsley
Nov 04 2016 13:38
I'm ok for kisses right now pal
Steven Kirk
@grokys
Nov 04 2016 13:38
:D
danwalmsley
@danwalmsley
Nov 04 2016 13:38
:)
Darnell Williams
@Seeker1437
Nov 04 2016 13:41
okay pushed!
danwalmsley
@danwalmsley
Nov 04 2016 13:47
ok just about to update Avalon Studio and see what happens ;)
Darnell Williams
@Seeker1437
Nov 04 2016 13:51
@grokys the sideffect of what you told me about using GetObservable also completely fixed the logical tree setup in Branch haha XD
nvm...
Darnell Williams
@Seeker1437
Nov 04 2016 14:05

Pussing this in the main room:

previously Branch was not managing or even trying to manage it's logical children.

Now it does, but ti only works partially and I can't understand why ti doesn't work fully:

So when the branch has just normal items in it
like buttons

(aka FirstItem = Button and SecondItem = Button)

I can see both buttons as logical children.

http://image.prntscr.com/image/c4d15d5615e64cc89c5e5f35a9100571.png

However if I have

<Branch
     <Button
     <Branch
        <Button
        <Button

only the Button and just the Branch (and not it's Logical children) are in the logical tree

http://image.prntscr.com/image/9b540dbfdab347018e4b124602851aaa.png

if the branch has two branches

<Branch
    <Branch
        <Button
        <Button
    <Branch
        <Button
        <Button

it does not have logical children at all...

http://image.prntscr.com/image/5ecb00814a5144ba91a36b446fd91d5d.png

danwalmsley
@danwalmsley
Nov 04 2016 14:06
so your saying if you put in a Branch plus any other control your logical tree is fine
but if you see first and second item to branches
then you don't anything below Branch or Button?
Darnell Williams
@Seeker1437
Nov 04 2016 14:07
I seen nothing beyond the root branch
Oh yes
ill post a pic really quick too
ill update above with the images
Darnell Williams
@Seeker1437
Nov 04 2016 14:13
updated
danwalmsley
@danwalmsley
Nov 04 2016 14:15
ok show me the line of code you use to manually connect your logical tree up
?
danwalmsley
@danwalmsley
Nov 04 2016 14:19
let me try the code...
immediately after those lines have run... if you get the logical ancestors of the newchild
what do you get?
Darnell Williams
@Seeker1437
Nov 04 2016 14:20
never thought to check actually
checking
Darnell Williams
@Seeker1437
Nov 04 2016 14:28
see it's correct in my tests
danwalmsley
@danwalmsley
Nov 04 2016 14:30
let me see what logical tree looks like when I run Avalon studio
Darnell Williams
@Seeker1437
Nov 04 2016 14:32
this is strang
our ContentProperty Observable isn't always being called???
Darnell Williams
@Seeker1437
Nov 04 2016 14:40
Okay so I feel like I am still doing something out of order xD
this is good! I am learning, xD
It's possible that the First and Second ContentPresenters may have had their values set before we get the Observable
danwalmsley
@danwalmsley
Nov 04 2016 14:45
@Seeker1437 does docknc publish nugget packages yet?
Darnell Williams
@Seeker1437
Nov 04 2016 14:48

NuGet

Mabiavalon.DockNC is delivered as a NuGet package.

Using the nightly build feed:

Add https://www.myget.org/F/mabiavalon-ci/api/v2 to your package sources
Update your package using Mabiavalon.DockNC feed
You can install the package like this:

Install-Package Mabiavalon.DockNC -Pre

;)
@danwalmsley
danwalmsley
@danwalmsley
Nov 04 2016 14:50
thanks
Darnell Williams
@Seeker1437
Nov 04 2016 15:01
have one more think to try xD
Darnell Williams
@Seeker1437
Nov 04 2016 15:07
okay fixed

@grokys after re-reading the logic you showed me, I realized I left out the equivalent of this code:

https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Mixins/ContentControlMixin.cs#L74

adding the correct equivalent fixed my logical tree issues :D

danwalmsley
@danwalmsley
Nov 04 2016 15:18
nice one!
will see if my Avalon studio issue fixes with this
looks promising
Steven Kirk
@grokys
Nov 04 2016 15:21
cool!
danwalmsley
@danwalmsley
Nov 04 2016 23:27
@jkoritzinsky nice one on the auto marshalling of property bindings to uithread
already taking advantage!!
although getting the occasional stack overflow
Darnell Williams
@Seeker1437
Nov 04 2016 23:56
DO you know how has administrative control over the avalonia myget feed?
and also the nuget feed?
danwalmsley
@danwalmsley
Nov 04 2016 23:57
@jkoritzinsky it seems it doesn't work for Lists and Collections however