Redth / Maui.VirtualListView

A slim ListView implementation for .NET MAUI that uses Platform virtualized lists / collections
MIT License
240 stars 32 forks source link

Can't add to a project if plain net8.0 support is present #21

Closed PavloLukianets closed 5 months ago

PavloLukianets commented 9 months ago

Failing to build if added to such project, because of this:

Screenshot 2024-01-22 at 9 54 29 PM

Redth commented 8 months ago

I'm going to look at merging this PR, but to be honest I'm conflicted. You shouldn't be trying to reference this type from net8.0 in your project. Can you provide more info about what code you are trying to use that is giving you this error?

themronion commented 8 months ago

Just added the net8.0 TF to support a test project

themronion commented 8 months ago

If u can recommend any other way to make a unit test project work with MAUI would be grateful!

eth-ellis commented 8 months ago

My team are experiencing the same issue due to having a test project in our solution.

That PR would greatly help us.

Currently we are working around by doing the below in our MauiProgram:

public static MauiAppBuilder ConfigureVirtualListView(this MauiAppBuilder mauiAppBuilder)
{
#if IOS || ANDROID
    mauiAppBuilder.UseVirtualListView();
#endif
    return mauiAppBuilder;
}

And to create a custom adapter creating the below classes:

#if NET && !IOS && !ANDROID
namespace Microsoft.Maui.Adapters
{
    public interface IVirtualListViewAdapter
    {
        void InvalidateData();
    }
}
#endif
#if NET && !IOS && !ANDROID
namespace Microsoft.Maui.Adapters
{
    public abstract class VirtualListViewAdapterBase<TSection, TItem>
        where TItem : class
    {
        public abstract TItem GetItem(int sectionIndex, int itemIndex);

        public abstract int GetNumberOfItemsInSection(int sectionIndex);
    }
}
#endif
eth-ellis commented 8 months ago

And to get the view working we did the below:

namespace MyHealth.Controls
{
    public class VirtualListView : Microsoft.Maui.Controls.VirtualListView
    {

    }
}

#if NET && !IOS && !ANDROID
namespace Microsoft.Maui.Controls
{
    public class VirtualListView : View
    {
                // Fake properties, methods and events
    }
}
#endif
rmorin04 commented 6 months ago

sill an issue with 0.3.2