These are chat archives for AvaloniaUI/Avalonia

2nd
May 2018
walterlv
@walterlv
May 02 2018 00:10
image.png
@jkoritzinsky It seems that when the child is larger than the grid column, it will render out of the column limitation.
Sergey Khabibullin
@x2bool
May 02 2018 07:02

I came up with this. But it renders only top-left quarter of the image

This actually seems to be a bug.

danwalmsley
@danwalmsley
May 02 2018 08:44
@walterlv is it to do with ClipToBounds?
walterlv
@walterlv
May 02 2018 08:45
You mean I should use ClipToBounds in the ArrangeOverride?
danwalmsley
@danwalmsley
May 02 2018 08:45
I'm not sure, but normally you set ClipToBounds = true to make the content not render outside its container
I think its normally true by default
is this bug in the new Grid code or existing code?
walterlv
@walterlv
May 02 2018 08:46
No
Old one also behaviors like this
danwalmsley
@danwalmsley
May 02 2018 08:46
ok
Benedikt Schroeder
@Gillibald
May 02 2018 08:46
ClipToBounds just effects the pixel alignment as far as i know
walterlv
@walterlv
May 02 2018 08:47
ClipToBounds only affects the container edge, not the grid column edge
danwalmsley
@danwalmsley
May 02 2018 08:47
there is a different property for that
Benedikt Schroeder
@Gillibald
May 02 2018 08:47
Looks like the available space isnt measured correctly
danwalmsley
@danwalmsley
May 02 2018 08:47
@walterlv do you have the XAML to repro that
so I can play around here
walterlv
@walterlv
May 02 2018 08:48
Yes, I posted the xaml in the pr AvaloniaUI/Avalonia#1517
It reproduces in both master and mine
danwalmsley
@danwalmsley
May 02 2018 08:49
ok thanks
and in wpf it behaves differently yes?
walterlv
@walterlv
May 02 2018 08:50
WPF behaviors different
Benedikt Schroeder
@Gillibald
May 02 2018 08:50
In all layout code i have seen so far ClipToBounds is used to scale Things
walterlv
@walterlv
May 02 2018 08:51
I confirm that the code in Layoutable reproduces this.
Because my code works correctly in WPF.
And works the same as the original Grid of Avalonia.
danwalmsley
@danwalmsley
May 02 2018 08:51
if WPF behaves differently then its definitely a bug
walterlv
@walterlv
May 02 2018 08:53
image.png
You may noticed that picture displaying the bug.
Benedikt Schroeder
@Gillibald
May 02 2018 08:53
I had a problem with the layout system myself if a child has Zero space it still gets rendered. Could be the same problem that a child doesn't obey its parents bounds. If a parent can increase size thats okay but if it can's this should not happen.
walterlv
@walterlv
May 02 2018 08:53
Actually, the above one is the original one, the below one is new.
Had a try?
Steven Kirk
@grokys
May 02 2018 08:59
WPF also has the concept of "layout clipping" which Avalonia does not have
walterlv
@walterlv
May 02 2018 08:59
If the container arrange bounds is smaller than the child desired size, WPF will arrange the child on the arrange position and then clip the child's right and bottom. However, Avalonia will move the child left and top to center it and render the whole child bounds.
Steven Kirk
@grokys
May 02 2018 09:01
there doesn't seem to be any documentation for layout clipping in WPF however
and I'm not sure we should reproduce it in avalonia
also @walterlv : don't assume our original grid behaved correctly. it was ported from moonlight and probably had bugs, as well as the differences in behavior between SL and WPF
walterlv
@walterlv
May 02 2018 09:06
@grokys Thanks, my algorithm behaviors the same to the original grid in common situation, but not the same in uncommon situation.
Steven Kirk
@grokys
May 02 2018 09:06
tbh i think that's fine
walterlv
@walterlv
May 02 2018 09:06
```<Grid Grid.Row="1" ColumnDefinitions="100,*,2*">
<Border Grid.Column="0" Background="CornflowerBlue" Width="150" />
<Border Grid.Column="1" Background="Tomato" Width="150" />
<Border Grid.Column="2" Background="Teal" Width="150" />
</Grid>
this code, if we add a columnspan=2 for the second one. the two grid behaviors different.
Steven Kirk
@grokys
May 02 2018 09:09
does your grid behave like WPF's grid in that case?
(if you ignore layout clipping)
walterlv
@walterlv
May 02 2018 09:09
No, because I think WPF also has bugs in that case.
Steven Kirk
@grokys
May 02 2018 09:10
yeah probably!
See this line in the code
I marked the bug
I don't know whether to simulate the WPF's bug or define a new behavior.
Steven Kirk
@grokys
May 02 2018 09:12
i saw do whichever is easiest/cleanest
we're not trying to implement WPF's API on a bug-for-bug basis
walterlv
@walterlv
May 02 2018 09:13
I'll write a simple reproduce xaml code for you. for WPF's bug. You'll know what it is.
Steven Kirk
@grokys
May 02 2018 09:13
btw does the new grid speed up the Calendar page in the control catalog?
danwalmsley
@danwalmsley
May 02 2018 09:14
@grokys I know gitter was down yesterday so I'm not sure if my info on AvaloniaUI/Avalonia#1326, I found out why I was having that issue, I was triggering error in databinding, which I can resolve in application code. However whats your thoughts on databinding error stopping treeview selection code from working correctly.
to remind you this is the issue I was seeing:
treeview-selection.gif
Steven Kirk
@grokys
May 02 2018 09:16
i don't understand what is causing the error: "Could not convert 'AvalonStudio.Controls.Standard.SolutionExplorer.SolutionFolderViewModel' to 'ProjectItemViewModel'." <-- that isn't Avalonia, right?
what do your XAML and view models look like? could you update the issue with that info?
danwalmsley
@danwalmsley
May 02 2018 09:40
sorry for delay
basically iv bound selecteditems
however because I have this binding error (it shows up as a warning)
it throws an exception in the selection code
iv fixed the bug in my code now
but I would have expected the binding to fail, but the controls selection logic to continue
it shouldn't have ended up with the control getting into a weird state
I'm wondering if you think I should try to fix that
walterlv
@walterlv
May 02 2018 10:15
<Window x:Class="LayoutDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:LayoutDemo"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Canvas>
            <Grid Height="100">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Border Grid.Column="0" Background="CornflowerBlue" Width="150" />
                <Border Grid.Column="1" Background="Tomato" Width="150" />
                <Border Grid.Column="2" Background="Teal" Width="150" />
            </Grid>
        </Canvas>
        <Grid Grid.Row="1" HorizontalAlignment="Right">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="2*" />
            </Grid.ColumnDefinitions>
            <Border Grid.Column="0" Background="CornflowerBlue" Width="150" />
            <Border Grid.Column="1" Grid.ColumnSpan="2" Background="Tomato" Width="200" />
            <Border Grid.Column="2" Background="Teal" Width="150" />
        </Grid>
        <Grid Grid.Row="2" HorizontalAlignment="Right">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="2*" />
            </Grid.ColumnDefinitions>
            <Border Grid.Column="0" Background="CornflowerBlue" Width="150" />
            <Border Grid.Column="1" Background="Tomato" />
            <Border Grid.Column="2" Background="Teal" Width="150" />
        </Grid>
    </Grid>
</Window>
These codes reproduce 3 wpf grid bugs. Unfortunately, I forgot how to reproduce the most strange one.
What you should do is to resize the Window and see what happens.
The first row: Change the third column * to 2* or other values, and you'll see that the third column is equals to the second one.
The second row and the third row: sorry I pasted wrong code.
walterlv
@walterlv
May 02 2018 10:22
The second row: If you change the width to 150 and 151, you'll see that a large white space appears.
Steven Kirk
@grokys
May 02 2018 10:24
@danwalmsley it's hard to say whether it's a bug from the info you posted. if you're binding to a SelectedItems collection for example, and the exception is preventing that collection from getting updated then I'd say it's not a bug
@walterlv yes indeed that sounds like a WPF bug I've encountered myself
danwalmsley
@danwalmsley
May 02 2018 10:39
@grokys in this case the treeview is set where only a single items can be selected
but when a binding error gets in the way, it changes the behavior
its only a minor niggle, but iv never seen a binding error change the behaviour of any of the other controls
I normally get a warning, but control works as normal
I'm binding to SelectedItem
basically user is clicking selected item, the treeview, tries to update the datacontext one, but a casting issue prevents this,
rest of treeviews selection logic, just stops where it was and doesn't unselect the previous item like it should
MonkAlex
@MonkAlex
May 02 2018 11:44
How to use UsePlatformDetect on app builder? When i compile and run this on windows - all work fine. When i reuse app on linux mint - not work, need set manual
Steven Kirk
@grokys
May 02 2018 12:00
@MonkAlex sounds like a bug
should be selecting GTK/Skia on linux - any idea what it's selecting that makes it not work?
MonkAlex
@MonkAlex
May 02 2018 12:02
need stacktrace, try to reproduce

bug$ mono MangaReader.Avalonia.exe

Unhandled Exception:
System.InvalidOperationException: No rendering subsystem found. Are you missing assembly references?
at Avalonia.AppBuilder.UsePlatformDetect () [0x001bc] in <206f00bf361b426fb0facf7f87649909>:0
at MangaReader.Avalonia.App.BuildAvaloniaApp () [0x00005] in <66cda25d71874dd6a0c5be57f6288503>:0
at MangaReader.Avalonia.App.Main (System.String[] args) [0x00001] in <66cda25d71874dd6a0c5be57f6288503>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: No rendering subsystem found. Are you missing assembly references?
at Avalonia.AppBuilder.UsePlatformDetect () [0x001bc] in <206f00bf361b426fb0facf7f87649909>:0
at MangaReader.Avalonia.App.BuildAvaloniaApp () [0x00005] in <66cda25d71874dd6a0c5be57f6288503>:0
at MangaReader.Avalonia.App.Main (System.String[] args) [0x00001] in <66cda25d71874dd6a0c5be57f6288503>:0

MonkAlex
@MonkAlex
May 02 2018 12:37
Hm, useplatformdetect differ then github source
Rayyan Tahir
@RayyanTahir
May 02 2018 12:46
Can't find Loaded event for Window
Steven Kirk
@grokys
May 02 2018 12:59
ah ok yeah i see you're using mono not .net core on linux
MonkAlex
@MonkAlex
May 02 2018 13:17
So, app runned in mono so slow. I test 0.4 avalonia last time and app be faster. Now just text type is unreal slow
MonkAlex
@MonkAlex
May 02 2018 13:39

Hm, no idea, how people profile on linux.
Mono say that:
Statistical samples summary
Sample type: cycles
Unmanaged hits: 112844 (99.6%)
Managed hits: 409 ( 0.4%)
Unresolved hits: 3627 ( 3.2%)
Hits % Method name
99184 87.58 read
6801 6.01 pthread_cond_timedwait
2294 2.03 __poll
183 0.16 _pthread_cleanup_push_defer

Exception summary
Throws: 372
Executed catch clauses: 371
Executed finally clauses: 663

danwalmsley
@danwalmsley
May 02 2018 13:42
@RayyanTahir there isn't a Loaded event yet.
unfortunately
Rayyan Tahir
@RayyanTahir
May 02 2018 13:43
@danwalmsley Would "Activated" event suffice in your opinion?
danwalmsley
@danwalmsley
May 02 2018 13:44
it may do!
you could also use
override OnAttachedToVisualTree
Rayyan Tahir
@RayyanTahir
May 02 2018 13:51
Okay, Thanks! :smile:
walterlv
@walterlv
May 02 2018 13:59
So is Loaded event necessary?
Rayyan Tahir
@RayyanTahir
May 02 2018 14:02
@walterlv in WPF, correct values of ActualWidth and ActualHeight appear once the control is loaded
So in some cases yes it is necessary
walterlv
@walterlv
May 02 2018 14:04
/// <summary>
/// This event is fired when the element is laid out, rendered and ready for interaction
/// </summary>
public event RoutedEventHandler Loaded
{
    add => AddHandler(LoadedEvent, value, false);
    remove => RemoveHandler(LoadedEvent, value);
}
@RayyanTahir I mean is it necessary for Avalonia?
Rayyan Tahir
@RayyanTahir
May 02 2018 14:07
I guess it is for those shifting their WPF projects to Avalonia.
But as @danwalmsley mentioned we could override OnAttachedToVisualTree then I guess that would suffice too
danwalmsley
@danwalmsley
May 02 2018 14:12
Loaded event could easily be added I think!
Rayyan Tahir
@RayyanTahir
May 02 2018 14:14
Speaking of adding features, IMHO Window background transparency needs to be implemented.
walterlv
@walterlv
May 02 2018 14:16
WPF transparency Window has very pool performance.
walterlv
@walterlv
May 02 2018 14:25
So do you have time to review and play the Grid? @danwalmsley @grokys @jkoritzinsky
danwalmsley
@danwalmsley
May 02 2018 14:35
@walterlv ok if its ready I can see if AvalonStudio is happy with it
and have a general play around
what did you decide to do about the issue you were talking about earlier where the content wasn't clipped to the column width?
walterlv
@walterlv
May 02 2018 14:38
  1. I'd like to build Avalonia Studio and play it. Where should I find it?
walterlv
@walterlv
May 02 2018 14:39
  1. The column clipping issue is not Grid's fault. So we can fix it later in another pull request.
danwalmsley
@danwalmsley
May 02 2018 14:39
ok cool
I will build AS against your pr now
walterlv
@walterlv
May 02 2018 14:41
  1. It's midnight by my watch, so I'm sleeping. (。◝‿◜。)
The gitter changed all my order number to 1.
danwalmsley
@danwalmsley
May 02 2018 14:43
ok ill let you know how I get on tomorrow :)
walterlv
@walterlv
May 02 2018 14:43
Thanks!
walterlv
@walterlv
May 02 2018 14:55
I can't wait to play Avalonia Studio. So how can I test my Grid?
Steven Kirk
@grokys
May 02 2018 17:03
@walterlv i believe @danwalmsley uses these scripts to overwrite his nuget cache with locally built binaries
danwalmsley
@danwalmsley
May 02 2018 17:04
@grokys I need to add a wiki page or something that explains this
like a How to Debug Avalonia under your Application page or something
Steven Kirk
@grokys
May 02 2018 17:05
yeah
there must be a better way than the "overwrite your cache" hack though
danwalmsley
@danwalmsley
May 02 2018 17:10
the other approaches iv tried was, build nuget packages locally, and use a local nuget source
that was a headache
then also using avalonia as a submodule that was worse too
but there maybe something you can do with msbuild files
Steven Kirk
@grokys
May 02 2018 17:11
we possibly need a quick way to build nuget packages locally from the artifacts generated by VS, instead of going via cake
danwalmsley
@danwalmsley
May 02 2018 17:14
@grokys i think I did a bad job of trying to explain the issue with tree view before do you have a minute I can try again?
Steven Kirk
@grokys
May 02 2018 17:16
i need to cook dinner right now, but I think i understood the problem, if not the exact repro
and it does indeed sound like a bug
first thing is a unit test demonstrating the problem
danwalmsley
@danwalmsley
May 02 2018 17:16
Ok, I think I can fix it
Ill try and submit a PR with test and fix
Steven Kirk
@grokys
May 02 2018 17:17
that would be great!
danwalmsley
@danwalmsley
May 02 2018 17:17
I just wanted to check it was something that needed fixing before I got into it
Steven Kirk
@grokys
May 02 2018 17:36
it sounds like it, but without knowing the details it's hard to say for sure
Edward Noorinejad
@EdwardNoorinejad
May 02 2018 19:11
Hi, I'm using AvaloniaUI and I'm not sure if I've stumbled upon a potential bug or if I'm doing something wrong. I am attempting to change the background of a ToggleButton based on its IsChecked property using the style pseudoclasses (Selector="ToggleButton[IsChecked=True]"). I get a Portable.Xaml.XamlObjectWriterException saying that it cannot convert the string to a nullable boolean. Here is some code that can replicate the inner exception:
var str = default(Selector).OfType<ToggleButton>().PropertyEquals(ToggleButton.IsCheckedProperty, true).ToString();
var p = new SelectorParser((s, o) => typeof(ToggleButton));
var r = p.Parse(str);
danwalmsley
@danwalmsley
May 02 2018 19:17
@EdwardNoorinejad your selector should be
Selector="ToggleButton:checked"
see if that works
@grokys ok so here is a hack / workaround for the treeview thing
possibly pointing to the issue being in SetAndRaise method...
ok here goes
public object SelectedItem
        {
            get
            {
                return _selectedItem;
            }

            set
            {
                if (_selectedItem != null)
                {
                    var container = ItemContainerGenerator.Index.ContainerFromItem(_selectedItem);
                    MarkContainerSelected(container, false);
                }

                SetAndRaise(SelectedItemProperty, ref _selectedItem, value);

                if(value != null && _selectedItem == null)
                {
                    _selectedItem = value;
                }

                if (_selectedItem != null)
                {
                    var container = ItemContainerGenerator.Index.ContainerFromItem(_selectedItem);
                    MarkContainerSelected(container, true);

                    if (AutoScrollToSelectedItem && container != null)
                    {
                        container.BringIntoView();
                    }
                }
            }
        }
you see when it calls SetAndRaise (this is from Treeview.cs btw)
if for some reason there is a binding error, on the datacontext, then _selectedItem ends up null.
the next 3 lines iv added as a workaround and that fixes the issue
if those lines are not there, then when the selected item is set again
the part before SetAndRaise cant be called and so the Container cannot be marked as not selected.
(How it gets selected in the first place I don't know.
but my question is,
should we fix SetAndRaise so that it always sets the backing field even when the binding throws an error?
or should we find a workaround that only fixes it for treeview
(my feeling is this could be reproduced on any items control)
Edward Noorinejad
@EdwardNoorinejad
May 02 2018 19:23
ToggleButton:checked worked, thank you
yowl
@yowl
May 02 2018 19:23
shouldn't it set the backing field before raising the event anyway
danwalmsley
@danwalmsley
May 02 2018 19:24
i guess that's the easier way to phrase it :)
danwalmsley
@danwalmsley
May 02 2018 19:42
@grokys ok its more in depth than I thought, iv added a repro and more details to the issue
I believe its related to the work @jkoritzinsky did on DefferedSetter
I will check in with him to see if he recognises the issue
Jeremy Koritzinsky
@jkoritzinsky
May 02 2018 19:43
I'll take a look when I have a chance. It's the end of the semester so I'm kinda busy rn.
danwalmsley
@danwalmsley
May 02 2018 19:44
now worries, I finally got a simple repro for it
:)
MonkAlex
@MonkAlex
May 02 2018 20:19
Anyone use Avalonia on mono, not dotnet core? UI freezing every event - mouse click, text input (every symbol), resize.
walterlv
@walterlv
May 02 2018 21:18
@danwalmsley @grokys My friend @JasonGrass has ever build a VS Extention to help to debug nuget package. This extensionhis a quick way to debug nuget package locally with source code and beakpoint. https://github.com/dotnet-campus/DllReferencePathChanger Maybe I have to ask him to translate it to English.