These are chat archives for AvaloniaUI/Avalonia

30th
Apr 2018
FuadNagiyev
@FuadNagiyev
Apr 30 2018 05:33
hey guys,
in my small avalonia app, which I'm coding - I have to react on a window size change - In WPF there was a SizeChangedInfo, from where you could get the new width and height of the window, and so one... is there an equivalent on Avalonia available?
FuadNagiyev
@FuadNagiyev
Apr 30 2018 05:38
I've already searched also OnResize method (which will be internally called from OnSizeChanged) - but I couldn't find it either
ahopper
@ahopper
Apr 30 2018 06:18
@FuadNagiyev have you tried subscribing to the ClientSize property?
FuadNagiyev
@FuadNagiyev
Apr 30 2018 06:24
@ahopper - no I haven't - but thats a good idea. thanks
Nils Kvist
@budRich
Apr 30 2018 08:26
hello people. I am trying to get to know avalonia and mvvm by doing a tutorial on pluralsight. I am trying to add a method to the "Loaded event handler, but It doesn't seem to exist in avalonia..
Do i have a missing using statement?
Nils Kvist
@budRich
Apr 30 2018 08:38
also get this build error: https://ptpb.pw/NmXO.png
telling me that the MainWindow class constructor must be parameterless...
danwalmsley
@danwalmsley
Apr 30 2018 08:41
@budRich good morning!
ok so your main window does need to be parameterless, because the XAML parser has to create it
and it doesn't know what parameters there are.
Its not correct typically to make MainWindow know about the ViewModel class, since that kind of defeats the point of MVVM pattern
so how to to set the MainViewModel on your main window
there are a few ways
probably the best way for you and easiest is
if you look at this line in the examples
the start method you can pass a lambda expression that creates the view model to be applied to the data context of your main window
as regards to the Window_Loaded event, what do you want to happen when the window has loaded?
Nils Kvist
@budRich
Apr 30 2018 08:46
I haven't gotten that far in the tutorial yet ;)
danwalmsley
@danwalmsley
Apr 30 2018 08:47
ah ok
well in avalonia you can do something like this, for code to run after everything is initialised just before it starts rendering your code.
Nils Kvist
@budRich
Apr 30 2018 08:47
i thought i would follow this tutorial and try to translate it to work with Avalonia and avalonstudio through out the course.
danwalmsley
@danwalmsley
Apr 30 2018 08:48
BuildAvaloniaApp()
                .AfterSetup(builder =>
                            {
                                // To do once application is initialised.
                            })
                .Start<MainWindow>(() => new MainWindowViewModel());
or if you want to have it when the window has definitely been shown you can try
this.Activated += (sender, e) =>
            {

            };
or override OnAttachedToLogicalTree instead
I think we have an issue for loaded event somewhere
Nils Kvist
@budRich
Apr 30 2018 08:51
ok. this is how the tutorial have it now: it passes a MainViewModel object to the constructor of the MainWindow, then add this MainViewModel object as the DataContext to the MainWindow (this worked), then executes the Load method of the MainViewModel by adding a loded method to the windows Loaded eventhandler.
Right now i just want to walk through this tutorial, and when needed find workarounds but still keeping to the path. Should i create an initialize method where i append the DataContext and execute the Loaded actions, and add that method with a lambda in Program.cs?
danwalmsley
@danwalmsley
Apr 30 2018 08:58
I guess it depends on what you want to do in the loaded event?
but you could do that
or just create the mainview model inside the main window constructor?
Nils Kvist
@budRich
Apr 30 2018 09:00
yeah, i think i will binge watch the whole tutorial before i start building it because right now i'm not sure exactly where it is going.. The tutor has refactored the code several times already and he will probably do that for this too.
danwalmsley
@danwalmsley
Apr 30 2018 09:03
oh btw did the fixes I pushed for AvalonStudio improve things?
Nils Kvist
@budRich
Apr 30 2018 09:22
ah. Forgot to check that, will try it now. (in the tutorial he now got the same errors and is building a workaround... well not the Loaded errors but constructor)
danwalmsley
@danwalmsley
Apr 30 2018 09:24
@budRich probably he is trying to show you why you shouldn't pass the viewmodel in the contructor
its better that way since you learn the reason for it
rather than someone like me just saying, don't do it that way do it this way ;)
it does make it difficult to code it up as he goes along though
Nils Kvist
@budRich
Apr 30 2018 09:28
yeah, :), i guess i could have made it easier for myself by just following the tutorial with visualstudio and wpf, but in the long run i think this is the fastest way for me to get to know avalonia and mvvm.
ok, buid done, hat should i test? renaming stuff in solexpl?
Nils Kvist
@budRich
Apr 30 2018 09:33
hmm
now renaming doesnt work at all..
danwalmsley
@danwalmsley
Apr 30 2018 09:40
try selecting
then single clicking
Nils Kvist
@budRich
Apr 30 2018 09:41
doesn't enter rename mode
lindexi
@lindexi
Apr 30 2018 13:02
AvaloniaUI/Avalonia#1532
Why not use string.Split to split the grid length string
I found the easy way to do it.
Benedikt Schroeder
@Gillibald
Apr 30 2018 14:50
How do we define a margin with comma seperated values if we have non en-us culture? The StringTokenizer doesn't work in that secenario and in my opinion margin(Thickness) shouldn't be culture aware.
That got just changed but i think nobody realy thought about that.
Does anyone know what was wrong about string.Split?
Steven Kirk
@grokys
Apr 30 2018 16:16
Do you mean AvaloniaUI/Avalonia#1125 ?
Benedikt Schroeder
@Gillibald
Apr 30 2018 16:16
exactly
Steven Kirk
@grokys
Apr 30 2018 16:19
So are got saying that PR broke things?
(sorry not at my computer right now)
"are you" not "are got"
Benedikt Schroeder
@Gillibald
Apr 30 2018 16:21
Yes kinda. If you define numeric values on machines that dont have an english culture (german for excample) some Tests or parse routines will fail.
In german we define double values with a comma not a dot. The introduced StringTokenizer or numeric value parsing in general always uses CultureInfo.CurrentCulture to parse a numeric value so a comma can't be used as a seperator or everything has to be culture independend (CultureInfo.InvariantCulture)
Steven Kirk
@grokys
Apr 30 2018 17:03
Ahhh yeah that sounds like a bug. @aelij what do you think?
danwalmsley
@danwalmsley
Apr 30 2018 18:44
@kekekeks good news, Ubuntu ditched Wayland in latest release :)
Steven Kirk
@grokys
Apr 30 2018 19:02
btw, i'm back now, though rather jet-lagged
what did i miss?
danwalmsley
@danwalmsley
Apr 30 2018 19:05
San Francisco again?
Core2d runs on CoreRT now
couldnt get AvalonStudio to run
load time was drastically improved
iv put a PR for context menus to stop them overlapping screen edges
AvaloniaUI/Avalonia#1526
@walterlv has written a new version of Grid which you may be interested to look at AvaloniaUI/Avalonia#1517
Steven Kirk
@grokys
Apr 30 2018 19:14
oh wow @walterlv - that's great!
just to check: none of this code comes from the Grid at https://referencesource.microsoft.com right?
Benedikt Schroeder
@Gillibald
Apr 30 2018 19:19
Looks totaly different what i have seen so far
sdoroff
@sdoroff
Apr 30 2018 19:21
I just posted a bunch of questions regarding the DataGrid in #1519
If people could take a look at some point this week, I'd greatly appreciate it.
Steven Kirk
@grokys
Apr 30 2018 19:24
nice one @sdoroff !
yeah i'm wondering where such a control should live too
i think i agree with you in saying a separate repo in the avalonia org
danwalmsley
@danwalmsley
Apr 30 2018 19:29
@jkoritzinsky #1526 I have corrected the issue you mentioned :)
@grokys If we add some of these new advanced controls to a separate repo, we will need to make sure the testing stuff is made available to them.
Steven Kirk
@grokys
Apr 30 2018 19:31
what testing stuff?
danwalmsley
@danwalmsley
Apr 30 2018 19:31
for example...
I cant find an example now
but you know like the stuff to create like the services required to do some tests
like the test version of the backends
iv seen some code somewhere in unit tests that does stuff like that
that gets configured in different ways, would that be needed by some people implementing controls?
if you know what I mean
I just cant remember the name of that stuff
Jeremy Koritzinsky
@jkoritzinsky
Apr 30 2018 19:35
You mean the UnitTestApplication class and the TestServices class?
danwalmsley
@danwalmsley
Apr 30 2018 19:35
yeah and stuff like this
perhaps it would be good to have like an Avalonia.UnitTesting nuget package
that people can get all that stuff from
or maybe its already available?
Jeremy Koritzinsky
@jkoritzinsky
Apr 30 2018 19:36
We don't have that, but we probably should.
danwalmsley
@danwalmsley
Apr 30 2018 19:37
i just remember a while back I wanted to do some simple test on a control I implemented
and tried copying some tests from avalonia to get started
but couldn't get hold of that stuff
so gave up in the end
@jkoritzinsky thanks for approval
Steven Kirk
@grokys
Apr 30 2018 19:56
ah yeah i agree that could be useful. however at the moment it's kinda linked to the tests we currently have
i think for the moment it'd be better to just copy/paste that code as it's likely to change quite a lot
and updating a nuget package would just slow things down even more
Benedikt Schroeder
@Gillibald
Apr 30 2018 20:35
CustomFonts will be a long road. Just got them working under DirectD21. Used resm sheme to load them. Have to figure out how to Cache them etc and support different FamilyFaces
jp2masa
@jp2masa
Apr 30 2018 21:16
I'd like to understand why are break chars skipped here: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Skia/Avalonia.Skia/FormattedTextImpl.cs#L339
the xaml white space chars are normalized before this, right? so I think that the only check here should be for line breaks (I think that this is causing some inconsistencies between direct2d and skia