These are chat archives for AvaloniaUI/Avalonia

19th
Dec 2018
Nikita Tsukanov
@kekekeks
Dec 19 2018 07:18 UTC
UWP has two major disadvantages:
1) Win10 only
2) API is more limited
Jonathan
@vanillajonathan
Dec 19 2018 08:59 UTC
Well, Windows 10 is a non-issue, since WPF is Windows 10 only, since anything before Windows 10 is irrelevant. But I heard that WPF was well-designed, and UWP was developed by a different team that didn't under XAML, hence UWP messed up and is worse than WPF. That people prefer the XAML of WPF over that of UWP.
Nikita Tsukanov
@kekekeks
Dec 19 2018 09:02 UTC
Yes, as I've said, the API is more limited
No custom markup extensions, shared size groups missing on Grid, etc
UWP has added some shiny "mobile-first" controls, but that's it
ahopper
@ahopper
Dec 19 2018 09:17 UTC
there are an awful lot of win7 users still out there http://gs.statcounter.com/windows-version-market-share/desktop/worldwide
Jonathan
@vanillajonathan
Dec 19 2018 09:19 UTC
Oh, 35.55% of Windows users. Hopefully soon much less. "Extended support until January 14, 2020"
Nikita Tsukanov
@kekekeks
Dec 19 2018 09:24 UTC
Won't go away until 2025, I think
WinXP is still there
So this is already implemented
Jonathan
@vanillajonathan
Dec 19 2018 09:29 UTC
Wikipedia says extended support for Windows 7 Pro and Enterprise ends on 2023.
Is there anything like resm:Avalonia.Themes.FluentDesignSystem.xaml ?
Nikita Tsukanov
@kekekeks
Dec 19 2018 09:32 UTC
I think @jmacato had something related to acrylic backround
Jumar Macato
@jmacato
Dec 19 2018 09:54 UTC
@vanillajonathan i have this gist for enabling acrylic bg on win10
though i havent tested that in a while
i'll make a sample project later and test that on my win10 vm
Jonathan
@vanillajonathan
Dec 19 2018 09:57 UTC
Yeah, UWP / Fluent Design System is more than just acrylic background. Its mobile-first, touch-friendly controls.
Binding: Error in binding to "Avalonia.Controls.TextBlock"."Text": "Null value in expression ''." <-- This message is not so friendly. It doesn't say in which UserControl or .xaml file this occurred in.
Jumar Macato
@jmacato
Dec 19 2018 09:58 UTC
yeah, no way i can provide that haha :)
Nikita Tsukanov
@kekekeks
Dec 19 2018 09:58 UTC
Unfortunately mobile-first usually means "desktop-unfriendly"
GNOME is a good example
Jonathan
@vanillajonathan
Dec 19 2018 09:59 UTC
I use GNOME, I think it is pretty good with the exception of the "dash" part of the GNOME Shell which the application grid, the launcher.
And the UWP app that comes with Windows 10, I don't think they are desktop-unfriendly.
I think Microsoft Edge uses UWP? That browser is not desktop unfriendly.
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:01 UTC
Mkay, complex UI unfriendly
To make controls touch-friendly one has to rethink the way of user interaction
Jonathan
@vanillajonathan
Dec 19 2018 10:02 UTC
Hmm, yeah I can agree with you on that. It's not so suitable for applications with dozens of buttons and menus maybe, such as an IDE.
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:02 UTC
Which leads to UI simplification
Jonathan
@vanillajonathan
Dec 19 2018 10:03 UTC
The web is mobile-first too. Bootstrap 4 is mobile-first. Everyone is doing mobile-first. It's the new thing. It's what people expect.
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:04 UTC
I guess so
It should be possible to implement these "mobile-first" UI elements, the needed infrastructure is there
There weren't enough demand for it during last 3 years of Avalonia development
Primary usage scenarios are desktop-first
So we were focusing on desktop
Jonathan
@vanillajonathan
Dec 19 2018 10:07 UTC
Oh, I didn't realize this project was so old
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:08 UTC
It's hard to get a brand new UI rendering engine if you aren't sponsored by Google or MSFT
So we are operating using scarce resources of community-driven project
Right now we have said multi-backend rendering engine, bindings and layout infrastructure that is mostly stable
So people can build their controls on top of that
We are really looking forward to finally releasing a stable public API which would be 1.0 version
Jonathan
@vanillajonathan
Dec 19 2018 10:11 UTC
I just found out about Avalonia. I knew about WPF and UWP but paid no attention to them. After MS announced open source and support for .NET Core, I peeked at WPF and UWP with some interest, and that's when I discovered Avalonia.
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:11 UTC
Which is why it's needed to focus on input methods and certnain Great New Wonderful Display Server Protocol from Linux
Since the support for them will introduce breaking changes
For now we only have X11 backend in development, I'm planning to do Wayland support this winter
Jonathan
@vanillajonathan
Dec 19 2018 10:13 UTC
Wayland is just displaying a buffer, so maybe its easier than X11
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:14 UTC
Wayland's API doesn't provide screen coordinates for surfaces
Which introduces certain complications for popup handling
One of the reasons for Wine not supporting wayland
Jonathan
@vanillajonathan
Dec 19 2018 10:14 UTC
Hmm, I see
GNOME runs on Wayland, also Firefox nightly
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:15 UTC
Also, we'll need to draw window decorations manually
instead of relying on window manager
I'm thinking about supporting KWin first
Since it has support for server decorations, DBus menus and blur-behind
Mutter support will come second
Another problem with wayland is the lack of libwayland bindings for .NET
So we'll have to write our own ones
Jonathan
@vanillajonathan
Dec 19 2018 10:17 UTC
Maybe there are libraries for Wayland that provide client-side decorations? https://github.com/Smithay/client-toolkit
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:18 UTC
I'd like to avoid shipping any native binaries
Unless we really have to
Skia is already a liability, but there is no other 2D graphics library that meets our requirements
It's fine to ship blobs for windows and mac os
But with a pandemonium of incompatible Linux distros I'd really like not to
Jonathan
@vanillajonathan
Dec 19 2018 10:26 UTC
ShouldUsePlatformDetect still exist in v1.0?
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:28 UTC
It's needed for platform backend selection unless we'll figure something using nuget/msbuild
That should be doable if we drop legacy .NET and Mono support
Jonathan
@vanillajonathan
Dec 19 2018 10:29 UTC
I see. As a developer, it seems like something I shouldn't have to call myself.
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:29 UTC
UsePlatformDetect lives in Avalonia.Desktop package
The rest of appbuilder logic lives in Avalonia package which is completely xplat
iOS and Android backends are using different initialization process
Which will be reworked
It's a boilerplate code from app template anyway
Jonathan
@vanillajonathan
Dec 19 2018 10:32 UTC
In ASP.NET Microsoft have a CreateDefaultBuilder method that does all default stuff. It looks like this: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/?view=aspnetcore-2.2&tabs=windows
ASP.NET also passes the string[] args to the Builder, which Avalonia does not.
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:34 UTC
I'd like not to mess with the command line of the UI application
They are usually meant for opening files with associated file extensions
Jonathan
@vanillajonathan
Dec 19 2018 10:34 UTC
I see
In Avalonia I need to override Initialize in App.xaml.cs, to call the XamlLoader, maybe I shouldn't have to do that. I don't know.
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:36 UTC
We can't assume that all your controls have an associated xaml resource
So we can't do that from the base constructor
Which brings us to codegen
Valters
@FaithLV
Dec 19 2018 10:36 UTC
Hey, I wrote a pretty heavy WPF application a year ago, but now that I'm using linux I'm planning on rewriting it on Avalonia. Everything seems cool, but is there any documentation about Window? How much of the properties align with WPF properties etc.?
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:37 UTC
See the list of properties here: http://avaloniaui.net/api/Avalonia.Controls/Window/
Valters
@FaithLV
Dec 19 2018 10:38 UTC
thanks, seems like i've missed it! <3
Nikita Tsukanov
@kekekeks
Dec 19 2018 10:39 UTC
Fine-grained control over the list of the buttons isn't there yet, but it shouldn't be that hard to implement
Jonathan
@vanillajonathan
Dec 19 2018 12:41 UTC
http://avaloniaui.net/docs/binding/bindings have a link to "change notifications" which is a 404.
Jonathan
@vanillajonathan
Dec 19 2018 12:51 UTC
If a <TextBlock Text="{Binding NumberOfApples}"> binds to NumberOfApples which is an integer, will it work? Even though Text should be a string, and the binding is to an integer?
Wouldn't it be better if FindControl() threw an Exception instead of returning null when not found?
Nikita Tsukanov
@kekekeks
Dec 19 2018 13:21 UTC
There is a difference between Find and Get
Binding to integer should be fine
Jonathan
@vanillajonathan
Dec 19 2018 13:22 UTC
Oh, great
When people use this.FindControl() shouldn't the expectation be that it always finds it? I got a NullReferenceException because it returned a null value. It was confusing. I can't imagine any scenario where someone would try find something they don't know exist.
Steven Kirk
@grokys
Dec 19 2018 13:37 UTC
@vanillajonathan but what if you did want to find a control that might not exist? you'd always have to catch an exception. exceptions should only be thrown IMO when something is wrong
Jonathan
@vanillajonathan
Dec 19 2018 13:38 UTC
I don't know if there is any such scenario. If there is, maybe there should be a GetControl method that throws exception.
Steven Kirk
@grokys
Dec 19 2018 13:38 UTC
also this is WPF and UWP's behavior
there's definitely such a scenario
it happens all the time in Avalonia's code
Jonathan
@vanillajonathan
Dec 19 2018 13:39 UTC
Ah, I see. I never used WPF and UWP. So I just thought it was weird it would return null instead of throw an exception when I attempted to retrieve something that I knew existed.
Jonathan
@vanillajonathan
Dec 19 2018 13:42 UTC
In order to bind a source property to a target, do I need a DataContext?
I don't need one that throws, it's just that from my constructor I want a reference to control, and having it not throw lead me into a headache when I didn't know it didn't find it, but I later got a NullReferenceException.
Steven Kirk
@grokys
Dec 19 2018 13:48 UTC
it's easier with a DataContext. you can do it without though if you really want to. but if you're doing that often you might want to rethink
Jonathan
@vanillajonathan
Dec 19 2018 13:49 UTC
I see. Doesn't DataContext break encapsulation of UserControls and violate the Single-Responsibility Principle?
Steven Kirk
@grokys
Dec 19 2018 13:50 UTC
you will usually have a view model for each view (i.e. UserControl) which contains the testable logic for the view
Jonathan
@vanillajonathan
Dec 19 2018 13:50 UTC
And make the UserControls less re-usable?
Steven Kirk
@grokys
Dec 19 2018 13:51 UTC
in my experience UserControls aren't really very re-usable anyway, if you're wanting a reusable control you'll usually want a lookless control
Jonathan
@vanillajonathan
Dec 19 2018 13:51 UTC
Ah, I see
Steven Kirk
@grokys
Dec 19 2018 13:52 UTC
it depends what you're writing really, if you can give any more details i might be able to point you in the right direction
Jonathan
@vanillajonathan
Dec 19 2018 13:53 UTC
Yeah, if I have a class that I need to represent in the UI. I don't know if I should create a UserControl or a Templated Control or a Basic Control.
Example, I need to show Strength, Intelligence, Wisdom, Dexterity, Constitution, and Charisma, so I have a class with a bunch of properties of type integer
Steven Kirk
@grokys
Dec 19 2018 13:59 UTC
are you wanting to ship this control as a library to be used in different apps?
note: i don't mean "might you want to in future" i mean "do you have that need now"
because if you only might have that need in future, any efforts you make to forsee that requirement will a) be wrong and b) wasted
just from experience ;)
Jonathan
@vanillajonathan
Dec 19 2018 14:06 UTC
No, I don't want to ship the control the used as a library. I just thought it made sense to always designs things encapsulated and according to single-responsibility principle and SOLID so that it use re-usable.
Because things with dependencies and tightly integrated, and not decoupled just seems like code smell to me.
So do I want a UserControl, a Templated Control or a Basic Control? and does using DataContext mean MVVM?
And should the controls have the context of the DataContext of its parent Window, or should each control have its view model?
Steven Kirk
@grokys
Dec 19 2018 14:15 UTC
well i mean you can do that, but if you're wanting to unit test, you're going to make things difficult for yourself. the generally accepted patterns for UI development generally split logic concerns from view concerns
i'd use a UserControl for your case
so you'd have a e.g. StatsView which is a UserControl and a StatsViewModel which backs it
you'd set StatsView.DataContext to an instance of StatsViewModel and bind to that
all your logic would be in StatsViewModel so you could unit test it
Jonathan
@vanillajonathan
Dec 19 2018 14:18 UTC
Thanks
Should the Windowhave a DataContextand view model too?
Steven Kirk
@grokys
Dec 19 2018 14:25 UTC
yeah i usually have a WindowViewModel
Jonathan
@vanillajonathan
Dec 19 2018 14:25 UTC
I guess I need the Avalonia.ReactiveUI package?
Steven Kirk
@grokys
Dec 19 2018 14:26 UTC
you don't need it
Jonathan
@vanillajonathan
Dec 19 2018 14:26 UTC
Oh, good
Steven Kirk
@grokys
Dec 19 2018 14:26 UTC
but it might make things easier
Jonathan
@vanillajonathan
Dec 19 2018 14:26 UTC
Do I need a ViewModelBase?
Steven Kirk
@grokys
Dec 19 2018 14:27 UTC
again, you don't need it, but it might make things easier
also: please not i've never written a game using MVVM, i'm not sure how much is relevant when you're writing a game vs an app (assuming you're writing a game)
Jonathan
@vanillajonathan
Dec 19 2018 14:33 UTC
I see
Steven Kirk
@grokys
Dec 19 2018 14:34 UTC
are you writing a game?
Jonathan
@vanillajonathan
Dec 19 2018 14:34 UTC
No, it was just an example.
Should my UserControl or my view model implement INotifyPropertyChanged ?
Steven Kirk
@grokys
Dec 19 2018 14:40 UTC
your view model implements INotifyPropertyChanged
Jonathan
@vanillajonathan
Dec 19 2018 14:40 UTC
THanks
Steven Kirk
@grokys
Dec 19 2018 14:40 UTC
if you google for WPF MVVM tutorial or similar, there's plenty of articles and most of it will apply to avalonia too
i really need to write a MVVM tutorial for Avalonia
Jonathan
@vanillajonathan
Dec 19 2018 14:42 UTC
I see
Jonathan
@vanillajonathan
Dec 19 2018 14:55 UTC
Wow, this thing is working! The values in the user control is changing! This is so amazing! I am so excited! :D
Steven Kirk
@grokys
Dec 19 2018 15:08 UTC
:D
Jonathan
@vanillajonathan
Dec 19 2018 15:11 UTC
It's great. All this works standard things like INotifyPropertyChanged and normal properties. No need for weird stuff like ReactiveUI or AvaloniaProperty.
But now the .xaml.cs files of all my user controls are empty, since all that code was moved out to the view models.
Jonathan
@vanillajonathan
Dec 19 2018 15:17 UTC
Oh, in my view models I always need to write boilerplate code so my setters call INotifyPropertyChanged. I cannot just write it as { get; set; }.
Avalonia ought to provide a ViewModelBase class that is decorated with an attribute that tells the compiler to rewrite all properties to call INotifyPropertyChanged.
Reed Copsey, Jr.
@ReedCopsey
Dec 19 2018 15:19 UTC
@kekekeks re: "if we drop legacy .NET and Mono support" <--- please don't drop .NET
Jonathan
@vanillajonathan
Dec 19 2018 15:25 UTC
Oh no, when I use emojis 😊😎😍 in Avalonia it doesn't show.
Jumar Macato
@jmacato
Dec 19 2018 15:38 UTC
@vanillajonathan all unicode text are currently being fixed
text handling*
Jonathan
@vanillajonathan
Dec 19 2018 15:38 UTC
Oh, great
Jumar Macato
@jmacato
Dec 19 2018 15:38 UTC
so i hope y'all hang on for a bit more till we get those working
Valters
@FaithLV
Dec 19 2018 15:41 UTC
Hey, in WPF for bitmaps there was an option to decode images. There was a particular issue of wanting to save images in whatever resolution provided, but to not hog up all the ram, you could decode them smaller thus reducing the resolution at runtime. Is there anything similar built-in in avalonia bitmaps or maybe it's not even needed?
Nikita Tsukanov
@kekekeks
Dec 19 2018 15:42 UTC
I guess you could use RenderTargetBitmap to resize the image after loading
and then use said RTB instead of the image
Would be a nice feature to have out of the box though
Valters
@FaithLV
Dec 19 2018 15:46 UTC
okay, thanks
Jeremy Koritzinsky
@jkoritzinsky
Dec 19 2018 17:04 UTC
@ReedCopsey what's your use case for wanting Avalonia on .NET Framework? What's blocking you from using .NET Core?
Reed Copsey, Jr.
@ReedCopsey
Dec 19 2018 17:04 UTC
want to integrate it into part of our main product, which uses a lot of C++/CLI still
going to take us a long time to get that reworked so we can use net core :(
Jeremy Koritzinsky
@jkoritzinsky
Dec 19 2018 17:18 UTC
C++/CLI is going to be supported on Windows on Core 3.0 btw. It's needed for WPF.
Reed Copsey, Jr.
@ReedCopsey
Dec 19 2018 17:28 UTC
did you see that from somewhere? last official word is "no plans to support C++/CLI on .NET Core"
BarsikTheCaT
@BarsikTheCaT
Dec 19 2018 17:38 UTC
Снимок экрана (194).png
what's going on here? I just added a listbox to the default project
ahopper
@ahopper
Dec 19 2018 17:39 UTC
you have probably got two root children in the window
BarsikTheCaT
@BarsikTheCaT
Dec 19 2018 17:43 UTC
Снимок экрана (195).png
I am no expert in markup, but I don't see the issue here
ahopper
@ahopper
Dec 19 2018 17:43 UTC
window can only have one direct child so you probably need to wrap your content in something like a grid or stackpanel
BarsikTheCaT
@BarsikTheCaT
Dec 19 2018 17:43 UTC
Well, that's weird
ahopper
@ahopper
Dec 19 2018 17:44 UTC
hello wold is one child and listbox is another
BarsikTheCaT
@BarsikTheCaT
Dec 19 2018 17:44 UTC
wait, content also counts as child?
ahopper
@ahopper
Dec 19 2018 17:45 UTC
yep because it is really a textblock (I think)
BarsikTheCaT
@BarsikTheCaT
Dec 19 2018 17:45 UTC
The more you know
And I thought html s bad
ahopper
@ahopper
Dec 19 2018 17:47 UTC
the problem is that html is bad and and has polluted your expectations :)
BarsikTheCaT
@BarsikTheCaT
Dec 19 2018 17:48 UTC
I think this is the main problem tho
Снимок экрана (193).png
I have no clue where to find info about this kinf of markup in general and interaction between different controls
Jeremy Koritzinsky
@jkoritzinsky
Dec 19 2018 17:51 UTC
@ReedCopsey I work on one of the CoreCLR teams. Also: dotnet/coreclr#18013
Reed Copsey, Jr.
@ReedCopsey
Dec 19 2018 17:51 UTC
Oh, nice :)
ahopper
@ahopper
Dec 19 2018 17:51 UTC
yep, try looking at the control catalog in the samples directory on github
Reed Copsey, Jr.
@ReedCopsey
Dec 19 2018 17:51 UTC
I missed that one
Jeremy Koritzinsky
@jkoritzinsky
Dec 19 2018 17:56 UTC
The compiler support for linking C++/CLI to core instead of framework isn't out yet though so you'll have to wait a little bit for that before you can try switching.
ahopper
@ahopper
Dec 19 2018 18:01 UTC
@BarsikTheCaT there are the generated docs http://avaloniaui.net/api/Avalonia.Controls/ListBox/ and wpf documentation combined with http://avaloniaui.net/docs/ covers a lot of ground