These are chat archives for AvaloniaUI/Avalonia

31st
May 2018
Steven Kirk
@grokys
May 31 2018 07:29
image.png
anyone waiting for that feature? :point_up:
ahopper
@ahopper
May 31 2018 07:50
@grokys that will neaten up a couple of things I've done :+1:
Jumar Macato
@jmacato
May 31 2018 07:55
@grokys this will make
my gitter client display markdown
:smile:
Jumar Macato
@jmacato
May 31 2018 08:01
well at least the basic markdown features :laughing:
Benedikt Schroeder
@Gillibald
May 31 2018 08:04
That looks awesome
Steven Kirk
@grokys
May 31 2018 08:17
cool!
still some work to do, but if you're interested it's on the textelements branch
as a bunch of WIP commits ;)
Nelson Carrillo
@nc4rrillo
May 31 2018 09:37
Sweet :)
Wiesław Šoltés
@wieslawsoltes
May 31 2018 09:39
Nice
Nelson Carrillo
@nc4rrillo
May 31 2018 09:45
Oh man there’s a gitter app for iOS that’s way better than the mobile site lol
Marcin Golonka
@meron1122
May 31 2018 12:10
I have short question, How to open new window from existing window and bind view model to it? I can make new MyNewWindow().Show() but where bind view model to it?
Wiesław Šoltés
@wieslawsoltes
May 31 2018 12:13
var window = new MyNewWindow();
window.DataContext = new ViewModelClass();
window.Show();
Nelson Carrillo
@nc4rrillo
May 31 2018 12:43
Q
danwalmsley
@danwalmsley
May 31 2018 13:02
@grokys AvaloniaUI/Avalonia#1629 looks good to me, were you happy with it?
Steven Kirk
@grokys
May 31 2018 13:03
ah yes thanks checking that out @danwalmsley - approved!
danwalmsley
@danwalmsley
May 31 2018 13:05
also AvaloniaUI/Avalonia#1553 could probably get merged with 1 minor change
Steven Kirk
@grokys
May 31 2018 13:13
what's the minor change?
should be an else?
danwalmsley
@danwalmsley
May 31 2018 13:34
@aelij are you around I think I found a pretty major bug in avaloniaedit weakevent manager but I probably need you to check my fix is good
Steven Kirk
@grokys
May 31 2018 14:07
ah yeah
@danwalmsley i'm not sure https://github.com/AvaloniaUI/Avalonia/pull/1553/files#diff-5a70961ef13114c94dceb228f4be6e72R653 should be there now that AvaloniaUI/Avalonia#1190 is merged
danwalmsley
@danwalmsley
May 31 2018 15:24
@grokys the point is that window state can go from minimized straight to maximized?
so renderer wont get restarted?
Steven Kirk
@grokys
May 31 2018 15:25
that code block is sending the window state change notification from a WM_SYSCOMMAND message
#1190 already implemented that in a different way
danwalmsley
@danwalmsley
May 31 2018 15:35
ok
Steven Kirk
@grokys
May 31 2018 17:46
@danwalmsley removed that duplicate functionality
danwalmsley
@danwalmsley
May 31 2018 21:21
@grokys you around? im trying to fix AvaloniaUI/Avalonia#1569
im surprised carousel isn't using like ItemVirtualizer or something similar like listbox does
should it?
Steven Kirk
@grokys
May 31 2018 21:36
hey @danwalmsley i'm here now
no, i don't think so
danwalmsley
@danwalmsley
May 31 2018 21:37
hey
Steven Kirk
@grokys
May 31 2018 21:37
the item virtualizer is meant for stacking multiple items in a viewport
danwalmsley
@danwalmsley
May 31 2018 21:37
ah ok
Steven Kirk
@grokys
May 31 2018 21:37
but carousel doesn't really work like that
danwalmsley
@danwalmsley
May 31 2018 21:37
basically I need to fix the reset case
Steven Kirk
@grokys
May 31 2018 21:37
it will either be displaying 1 or 2 items
danwalmsley
@danwalmsley
May 31 2018 21:38
we are trying to use the carousel for displaying selected tabs in docking
but obviously this issue keeps causing weird issues.
im not really sure what needs to happen when ItemsChanged gets called..
it seems to support some kind of virtualization
protected override void ItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            // TODO: Handle items changing.           
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Remove:
                    if (!IsVirtualized)
                    {
                        var generator = ItemContainerGenerator;
                        var containers = generator.RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                        Panel.Children.RemoveAll(containers.Select(x => x.ContainerControl));
                    }
                    break;

            }
        }
if the items get reset, do I need to remove all and re-add them all?
danwalmsley
@danwalmsley
May 31 2018 21:46
ah reset is just clear all items
Steven Kirk
@grokys
May 31 2018 21:53
yeah reset means "everything has changed, reload it all"
danwalmsley
@danwalmsley
May 31 2018 21:55
Iswitch (e.Action)
            {
                case NotifyCollectionChangedAction.Remove:
                    if (!IsVirtualized)
                    {
                        var generator = ItemContainerGenerator;
                        var containers = generator.RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                        Panel.Children.RemoveAll(containers.Select(x => x.ContainerControl));
                    }
                    break;

                case NotifyCollectionChangedAction.Reset:
                    if(!IsVirtualized)
                    {
                        var generator = ItemContainerGenerator;
                        var containers = generator.Containers.ToList();
                        generator.Clear();
                        Panel.Children.RemoveAll(containers.Select(x => x.ContainerControl));
                    }
                    break;

                case NotifyCollectionChangedAction.Add:
                    Panel.Children.InsertRange(e.NewStartingIndex, e.NewItems.OfType<IControl>());
                    break;

                case NotifyCollectionChangedAction.Replace:
                    if (!IsVirtualized)
                    {
                        for (var i = 0; i < e.OldItems.Count; ++i)
                        {
                            var index = i + e.OldStartingIndex;
                            var child = (IControl)e.NewItems[i];
                            Panel.Children[index] = child;
                        }
                    }
                    break;

                case NotifyCollectionChangedAction.Move:
                    Panel.Children.MoveRange(e.OldStartingIndex, e.OldItems.Count, e.NewStartingIndex);
                    break;                   
            }
this is my proposed fix, does that look right to you?
also what I don't understand is if this method didn't handle the Add case before. how was it getting items in it?
Steven Kirk
@grokys
May 31 2018 22:03
well add would add items to the end, which would by definition not be being shown
danwalmsley
@danwalmsley
May 31 2018 22:04
so in current code there is no add
Steven Kirk
@grokys
May 31 2018 22:04
re: that code - you don't want to add an item to the panel if it's virtualized do you?
danwalmsley
@danwalmsley
May 31 2018 22:05
this is a bit over my head :)
Steven Kirk
@grokys
May 31 2018 22:05
what don't you understand?
danwalmsley
@danwalmsley
May 31 2018 22:06
can you give me a sentence to describe what the carousel is exactly, possibly iv misunderstood what its supposed to do
like if this was listbox Id know why it handled, add, remove, reset, etc
but carousel only handled remove when I first came to the code
is it because it must only show a single item at a time?
Steven Kirk
@grokys
May 31 2018 22:07
yeah
it briefly shows 2 if there's a transition
but other than that it just displays 1 item
danwalmsley
@danwalmsley
May 31 2018 22:07
ok
so why did it not need to handle add before?
sorry for being dumb on this one! :)
Steven Kirk
@grokys
May 31 2018 22:09
haha i keep trying to work out how to explain it
ok, imagine you have 2 items and you're displaying the second
then you add a 3rd
you don't need to display that because it's not the current item
if you have 2 items and you're displaying the second
then the second gets removed
then you need to not display it
does that make sense now?
danwalmsley
@danwalmsley
May 31 2018 22:12
I think so
almost :)
Steven Kirk
@grokys
May 31 2018 22:13
This message was deleted
danwalmsley
@danwalmsley
May 31 2018 22:13
hahaha :)
Steven Kirk
@grokys
May 31 2018 22:13
gave up on that one
i mean probably the carousel should have handled more cases before
definitely move, insert
danwalmsley
@danwalmsley
May 31 2018 22:14
but not Add
it seems most of the time either Remove or Reset get called
Steven Kirk
@grokys
May 31 2018 22:15
no, because the added item won't be displayed yet
danwalmsley
@danwalmsley
May 31 2018 22:15
iv not seen any other case get called
Steven Kirk
@grokys
May 31 2018 22:15
that will depend on whether you add a new item to the bound collection or not
danwalmsley
@danwalmsley
May 31 2018 22:16
ok
does this look sensible?
   case NotifyCollectionChangedAction.Remove:
                    if (!IsVirtualized)
                    {
                        var generator = ItemContainerGenerator;
                        var containers = generator.RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                        Panel.Children.RemoveAll(containers.Select(x => x.ContainerControl));
                    }
                    break;

                case NotifyCollectionChangedAction.Reset:
                    if(!IsVirtualized)
                    {
                        var generator = ItemContainerGenerator;
                        var containers = generator.Containers.ToList();
                        generator.Clear();
                        Panel.Children.RemoveAll(containers.Select(x => x.ContainerControl));
                    }
                    break;

                case NotifyCollectionChangedAction.Replace:
                    if (!IsVirtualized)
                    {
                        for (var i = 0; i < e.OldItems.Count; ++i)
                        {
                            var index = i + e.OldStartingIndex;
                            var child = (IControl)e.NewItems[i];
                            Panel.Children[index] = child;
                        }
                    }
                    break;

                case NotifyCollectionChangedAction.Move:
                    Panel.Children.MoveRange(e.OldStartingIndex, e.OldItems.Count, e.NewStartingIndex);
                    break;                   
            }
Steven Kirk
@grokys
May 31 2018 22:18
hard to say just looking at it. does it work?
i think you'll need to regenerate the current container on reset
on remove too
it would be worth writing unit tests
danwalmsley
@danwalmsley
May 31 2018 22:21
Seems to, but from the issue its hard to tell how the bug is triggered
But since changing that I can't get the carousel out of sync
Il try and add some. Unit tests tomorrow
danwalmsley
@danwalmsley
May 31 2018 22:33
If I swapped
until after the event is raised
is that a bad thing to do?
the reason is, Reset clears out the Panel, causing unit test to fail
doesnt seem correct, because calling PanelCreated regenerates the container anyway
Steven Kirk
@grokys
May 31 2018 22:51
i think that'd probably break other itemspresenters
danwalmsley
@danwalmsley
May 31 2018 22:52
yeah it did
with my use case of a tabcontrol
Steven Kirk
@grokys
May 31 2018 22:53
panelcreated shoudn't be generating containers
i can't see where it is
the item reset following it should cause the containers to be generated
danwalmsley
@danwalmsley
May 31 2018 22:54
where all the items in the tab control are kept in memory even when they are not visible is it a mistake to use carousel then?
Steven Kirk
@grokys
May 31 2018 22:54
that's what the virtualization setting does
tells it whether to keep containers alive when not visible or not
that's consistent with other uses of virtualization
Nelson Carrillo
@nc4rrillo
May 31 2018 22:59
@grokys I made the changes you requested to #1631
danwalmsley
@danwalmsley
May 31 2018 23:00
@jkoritzinsky
public static readonly AttachedProperty<Control> PreviewWithProperty = AvaloniaProperty
            .RegisterAttached<Style, Control>("PreviewWith", typeof (Design));
Steven Kirk
@grokys
May 31 2018 23:00
cool! just about to go to bed now so will take a look tomorrow
danwalmsley
@danwalmsley
May 31 2018 23:00
Design.cs
it crashes I think because of Style there
Steven Kirk
@grokys
May 31 2018 23:00
night @danwalmsley, hope you get to the bottom of it ;)
danwalmsley
@danwalmsley
May 31 2018 23:00
should it have been Control?
@grokys thanks
I think I need to goto sleep too
I get
Exception thrown: 'System.Security.VerificationException' in Avalonia.Controls.dll
Method Avalonia.AvaloniaProperty.RegisterAttached: type argument 'Avalonia.Styling.Style' violates the constraint of type parameter 'THost'.
Jeremy Koritzinsky
@jkoritzinsky
May 31 2018 23:03
What's crashing?
danwalmsley
@danwalmsley
May 31 2018 23:04
im trying to work out if its some weird mix of old and new binaries
which dlls were affected by that PR?
just Avalonia.Controls and Avalonia.DesignerSupport right?
Jeremy Koritzinsky
@jkoritzinsky
May 31 2018 23:05
Avalonia.Styling
We had to change the Style type to inherit from AvaloniaObject.
danwalmsley
@danwalmsley
May 31 2018 23:05
ok
Jeremy Koritzinsky
@jkoritzinsky
May 31 2018 23:05
It didn't actually affect Avalonia.Controls IIRC
danwalmsley
@danwalmsley
May 31 2018 23:06
I recopied the dlls and it went away
sorry :)
Nelson Carrillo
@nc4rrillo
May 31 2018 23:45
nice I got WGL working :D, I just need to tidy up the code and api a bit