Welcome to the .NET MAUI feedback portal. We’re happy you’re here! If you have feedback on how to improve the .NET MAUI, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

1
Vote

Hi Syncfusion Team,

For reusability, I calculate SpanCount in BaseContentPage (which inherits from ContentPage) in its overrided OnSizeAllocated:


public int SpanCount { get; set; } = 1;


protected override void OnSizeAllocated(double width, double height)

    {

        base.OnSizeAllocated(width, height);

        App.ItemWidthFixed = (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density) < 500 ? (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density) : 320;

        PageWidth = width;

        int spanCount = (int)(PageWidth / App.ItemWidthFixed);

        SpanCount = spanCount < 1 ? 1 : spanCount;

        ItemWidth = PageWidth / spanCount;

    }

----------------------------

Then, the Page containing the SfListView is inherited from this BaseContentPage. I bind the SpanCount to it to ensure dynamic layout based on window size changes:

<lv:SfListView.ItemsLayout>

<lv:GridLayout SpanCount="{Binding SpanCount}"/>

</lv:SfListView.ItemsLayout>

----------------------------


By putting the SpanCount calculation in BaseContentPage, I preserve simplicity and avoid redundant codes each time those dynamic SfListViews are written.


This code works in Xamarin, but not in MAUI.

Could you please check if such simplicity can be provided in MAUI too?