These are chat archives for AvaloniaUI/Avalonia

4th
Jan 2019
Luis von der Eltz
@toytonics
Jan 04 10:05
is there a PropertyUnEquals selector? like "Button[Foo!=Bar]"
ksigne
@ksigne
Jan 04 10:19
well, I examined #2191 in details and found that UserControl generated from Template is missing Template for some reason
I believe it is because it doesn't catch styles
ksigne
@ksigne
Jan 04 10:32
it is due to EndInit() on styledelement have _initCount > 0 and increasing, and also _isAttachedToLogicalTree is false
so it looks like styles should be initialized on OnAttachedToLogicalTreeCore but it is not fired..
Alberto García Hierro
@fiam
Jan 04 12:39
Hi. I'm trying to build the desktop catalog sample on macOS using dotnet build, but Avalonia.Markup.Xaml fails to build with lots of errors regarding missing namespaces and references (e.g. The type or namespace name 'Markup' does not exist in the namespace 'Portable.Xaml). Should I report an issue?
Ok, looks like you're using submodules and the build system does not check for their presence
Steven Kirk
@grokys
Jan 04 13:00
@mstr2 yes that is an optimization i'm interested in, however i had something in mind that is a little more involved which would help solve the currently #1 perf problem (after #2088 and #2127 are merged)
which is sending property change notificiations when an object's inheritance parent is changed
and when an object is initialized
i've been using jetbrains dotmemory with a modified controlcatalog and using the profiler API to start/stop profiling at the correct place to detect the perf problems with the calendar page
afaics reading inherited values in "normal" situations isn't really a problem
the problem comes when initializing the object and changing the inheritance parent
Steven Kirk
@grokys
Jan 04 13:10
@fiam how do you make msbuild check for the presence of a submodule?
@ksigne hmm that sounds like a bug
Alberto García Hierro
@fiam
Jan 04 15:07
@grokys It depends. I'm not sure how your build is set up.
ksigne
@ksigne
Jan 04 15:50
@grokys look. In ContentPresenter.cs there is code to update child
```public void UpdateChild()
{
var content = Content;
var oldChild = Child;
var newChild = CreateChild();
        // Remove the old child if we're not recycling it.
        if (oldChild != null && newChild != oldChild)
        {
            VisualChildren.Remove(oldChild);
        }

        // Set the DataContext if the data isn't a control.
        if (!(content is IControl))
        {
            DataContext = content;
        }
        else
        {
            ClearValue(DataContextProperty);
        }

        // Update the Child.
        if (newChild == null)
        {
            Child = null;
        }
        else if (newChild != oldChild)
        {
            ((ISetInheritanceParent)newChild).SetParent(this);                                

            Child = newChild;

            if (oldChild?.Parent == this)
            {
                LogicalChildren.Remove(oldChild);
            }

            if (newChild.Parent == null)// && TemplatedParent == null)
            {
                LogicalChildren.Add(newChild);
            }

            VisualChildren.Add(newChild);
        }

        _createdChild = true;
    }```
you see I've removed TemplatedParent == null and it solves #2191
why was it originally there?
ahopper
@ahopper
Jan 04 16:25
@grokys I'd come to a similar view on the property system and had been wondering about a short term cache during initialization and styling
Steven Kirk
@grokys
Jan 04 17:33
@ksigne that check was added by AvaloniaUI/Avalonia@9b68067
ContentPresenter should only be manually setting its child's logical parent when it is outside of a control template. When it's inside a control template, setting the logical parent will be handled by ContentControlMixin.
tbh i now think that ContentControlMixin is probably a mistake
that logic is just too had to understand
ksigne
@ksigne
Jan 04 17:35
let me run
i'm trying to understand why does ContentControlMixin doesn't finally call ISetLogicalParent.SetParent
well, tests are green
ksigne
@ksigne
Jan 04 17:40
a lot of logic is too hard to understand and debug in Avalonia as far as it uses lots of anonymous and orphaned objects :(
there is no god object you can attach and track all things going on
ahopper
@ahopper
Jan 04 18:16
@ksigne this is an interesting point, I suspect the real problem is the debugging world is lagging behind the whole anonymous and lambda movement in modern code
ksigne
@ksigne
Jan 04 18:20
when I design desktop app I always create god object that contains all references at least as WeakReference. this is usually considered as a bad practice but this helps my life a lot
at least when you are out of time you can build a workaround with manipulating god object and then rework it later
ahopper
@ahopper
Jan 04 18:26
I can see the attraction in that. I comfort myself in the view that if the debugger is not keeping up with you, you are at least not falling behind the times :)
ksigne
@ksigne
Jan 04 18:28
well, software is made to work and be changed, not just be modern lol
every js developer should put it on their room wall
ahopper
@ahopper
Jan 04 18:34
every js developer should be put on their room wall
sorry, could not resist
ahopper
@ahopper
Jan 04 18:42
I feel I'm allowed to be rude about js developers as I wrote my first js spa 22 years ago http://www.ariadne.ac.uk/issue15/cover
Steven Kirk
@grokys
Jan 04 18:44
i think i'm going to try rewriting how ContentControl and ContentPresenter interact. I've never been happy with it
ksigne
@ksigne
Jan 04 18:45
I'm generally don't understand why do you need ContentControl at all
Why can't you stay with just ContentPresenter?
ksigne
@ksigne
Jan 04 18:56
If it is just ContentPresenter wrapped into Template, why TemplateBinding is not enough as an interaction?
Steven Kirk
@grokys
Jan 04 19:32
it comes from WPF
and ContentPresenter is used in controls other than ContentControl
this is a decent basic explanation of why you have the separation https://stackoverflow.com/a/1288353/6448
ksigne
@ksigne
Jan 04 19:56
@grokys it is a declaration rather than an explanation :@
so these two act identically except ContentControl has template itself
Steven Kirk
@grokys
Jan 04 19:56
i think "ContentControl is a base class for controls that contain other elements and have a Content-property (for example, Button)." says it all really?
ksigne
@ksigne
Jan 04 19:57
why ContentPresenter cannot be a base class for such controls?
because it doesn't inherit from TemplatedControl?
Steven Kirk
@grokys
Jan 04 19:58
because say you want a circular Button
and in the circle you want the Button.Content
that's the role of ContentPresenter
ksigne
@ksigne
Jan 04 19:59
well, I look at this things more monadic way
there are elementary IVisual and iControl that can be used to construct complex UIs
so there is Panel which is elementary [IControl, IControl…] -> IControl composition
there is ContentPresenter which is elementary (object, DataTemplate) -> IControl composition
there is ItemsPresenter which is elementary (IList, DataTemplate) -> IControl composition
for me the rest is build on top of these and primitive geometries
Steven Kirk
@grokys
Jan 04 20:03
great!
go do it!
ksigne
@ksigne
Jan 04 20:04
do what?
Steven Kirk
@grokys
Jan 04 20:04
that's not how WPF, UWP, web components or avalonia work however
you can do all that if you want to
but it's another framework
ksigne
@ksigne
Jan 04 20:05
idk, I usually do lots of custom controls in my apps, and lots of them just drawing on canvas - because it is much faster
Steven Kirk
@grokys
Jan 04 20:06
honestly. it really sounds like you just want your own framework here
i've tried myself many times to come up with something new
it's a lot of work, but it'd be worth it if you can see it through
ksigne
@ksigne
Jan 04 20:07
to tell the truth, if I can understand details of design well, I can build another on top, and it can be better in some aspects
just now i'm just crawling over the code, building demos and writing notes how all things works
Steven Kirk
@grokys
Jan 04 20:08
you could just use the low-level parts, like the scene graph, visuals etc if you want
ksigne
@ksigne
Jan 04 20:09
yes that's what I want, but i'll have to understand deeply how they are working inside
and I generally like DependencyProperty as better system to build complex systems
Steven Kirk
@grokys
Jan 04 20:10
meanwhile most people are using avalonia are wanting us to move closer to WPF so i don't think we'll be changing direction
ksigne
@ksigne
Jan 04 20:10
that's a good point indeed
being sync with WPF is a good direction anyway
Steven Kirk
@grokys
Jan 04 20:11
in fact if i could go back in time, i'd do less experimentation
either that or come up with something completely different
ksigne
@ksigne
Jan 04 20:12
WPF didn't became on par even with WinForms for app market share, well
but ideas inside it definitely very good
idk if it is any good to make something completely different
Steven Kirk
@grokys
Jan 04 20:13
it'd be interesting at least! but a lot of work
Stano Turza
@Sorien
Jan 04 20:31
I would say people for some reason think that avalonia is multiplatform rewrite of WPF and so they expect to be 1:1 with WPF in every context
ahopper
@ahopper
Jan 04 20:32
@grokys I reckon you have the balance spot on with the 'like wpf but better approach'
mstr2
@mstr2
Jan 04 20:53
To be fair, "multiplatform rewrite of WPF" is a far better value proposition to many people than "yet another new paradigm".
ksigne
@ksigne
Jan 04 20:54
@mstr2 why wouldn't then ms make uwp just a port of wpf? :D
mstr2
@mstr2
Jan 04 20:58
I would consider UWP a port of WPF that skips some of the more complex features, but adds support for more platforms and programming languages.
The problem with new paradigms and exotic frameworks is the lack of a strong user base with a large knowledge ecosystem (i.e. if you have a question, can you google an answer?). If Avalonia manages to keep itself aligned very closely to the existing XAML ecosystem, it can draw from the enormous problem-solving knowledge that is already available.
ksigne
@ksigne
Jan 04 21:04
Honestly, it cans. You can't just use WPF cookbook to build app with Avalonia. 3/4 of examples won't work, and you'll be stuck until you dive into sources
mstr2
@mstr2
Jan 04 21:04
And that, in turn, helps the adoption of the framework. Many stakeholders of large projects are very reluctant to invest in unicorn technologies for which they can't easily find people who know how to work with it.
Of course, it's not as easy as copy-and-paste. You'll need to make some adjustments, but the concepts are similar enough.
ksigne
@ksigne
Jan 04 21:06
Yes, but concepts and details are different things.
My idea is to stick with elementary concepts and build things hierarchically
It's like exercises with functional programming
And I think managed properties, styling and XAMLs are more useful than just handling UI notifications. I think of them as a DI replacement
mstr2
@mstr2
Jan 04 21:10
I understand that, but I think the most important question is whether you can bring in a team of developers familiar with WPF or UWP, and have them be able to quickly develop applications using the same methodologies they are already familiar with. Otherwise you'll need to re-train those people, at least enough so they are familiar with your new or changed set of concepts. And that's a hard sell to businesses.
ksigne
@ksigne
Jan 04 21:11
That's nothing different what i'm thinking about
mstr2
@mstr2
Jan 04 21:12
Maybe you could think of ways to make this an optional extension, rather than a core feature proposition. Then it could maybe get some real-world traction.
ksigne
@ksigne
Jan 04 21:13
what exactly? :D
mstr2
@mstr2
Jan 04 21:17
The idea you laid out earlier, using some kind of composition to construct complex UI. My understanding is that you proposed to change the meaning of core classes. I'm suggesting that you think of a concept to get your way that does not need to interfere with existing classes.
ksigne
@ksigne
Jan 04 21:17
you don't need to change it, as they are mostly ok now :D
some things are just looks redundant and not really generalized
but I don't think I can develop a well-generalized system just in the moment...
maybe if I move on with describing existing things I can deduce of simpler control set