These are chat archives for AvaloniaUI/Avalonia

28th
Jan 2015
José Manuel Nieto
@SuperJMN
Jan 28 2015 21:37
hey! I have investigated about the whole deferred loading thing and I have come to a conclusion: it's not ready to read N templates
It seems the mechanism that XamlReader has for templates is ready to accept just a single instance of the "template"
as soon as it's inside a collection, it parses the items of the collection as "objects"
Steven Kirk
@grokys
Jan 28 2015 21:39
Cant you just surround then in a DataTemplates object?
José Manuel Nieto
@SuperJMN
Jan 28 2015 21:39
and doesn't trigger any templating logic
I can try to do that
but I don't know what are the issues that I could find doing that :P
I have another alternative to the out-of-the-box deferred loading
if this doesn't work, I have a plan B
Steven Kirk
@grokys
Jan 28 2015 21:45
What's that?
José Manuel Nieto
@SuperJMN
Jan 28 2015 21:48
aha! it doesn't work
since the DataTemplates property is IEnumerable, it ignores it completely
I can confirm it because I have just created an ad-hoc property for ItemsControl that is a XamlDataTemplate and this way, the correct lookup for a deferred loader is made
Steven Kirk
@grokys
Jan 28 2015 21:50
I'm not at my computer at the moment but I thought that DataTemplates was of type DataTemplates which is a collection of IDataTemplates
José Manuel Nieto
@SuperJMN
Jan 28 2015 21:50
yes, that's the problem, I think
it's not a datatemplate, but a bunch of them
I think that complicates the scenario
I don't even know if the mechanism could work with N templates
I did this temporarily:
    protected override XamlValueConverter<XamlDeferringLoader> LookupDeferringLoader()
    {
        if (this.UnderlyingType == typeof(XamlDataTemplate))
        {
            return new XamlValueConverter<XamlDeferringLoader>(typeof(TemplateContentLoader), schemaContext.GetXamlType(typeof(XamlDataTemplate)));
        }

        var lookupDeferringLoader = base.LookupDeferringLoader();

        return lookupDeferringLoader;
    }
Steven Kirk
@grokys
Jan 28 2015 21:52
But you should be able to add items to the collection in xaml just by declaring them
José Manuel Nieto
@SuperJMN
Jan 28 2015 21:52
yes, I know
look at that
Steven Kirk
@grokys
Jan 28 2015 21:53
I can't really see it as I'm on my phone
José Manuel Nieto
@SuperJMN
Jan 28 2015 21:53
UnderlyingType is never XamlDataTemplate
oh, OK
Maybe there is another way, but I cannot figure out how to do it :(
Steven Kirk
@grokys
Jan 28 2015 21:53
If you're online tomorrow let's try and get it building on my machine
José Manuel Nieto
@SuperJMN
Jan 28 2015 21:54
OK!
I don't know if I'll be busy
at work, they have started to rush!
but I'll try :)