Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] In .Net 8 MAUI VisibleViews property of CarouselView is not working #15881

Closed
AmanGoyal009 opened this issue Apr 17, 2024 · 2 comments
Closed
Labels
s/unverified New report that has yet to be verified t/bug 🐛

Comments

@AmanGoyal009
Copy link

Description

In .Net 8 MAUI we are trying to get the current view using VisibleViews property. But we are getting an empty list everytime. Even though items are visible in the Carousel View and user can properly interact with the UI also.

Steps to Reproduce

  1. Create one Carousel View in the XAML File.
  2. Create one Submit Button.
  3. Once data is visible inside Carousel View click on the submit button and try to access the VisibleViews property. It will give empty collection.

Expected Behavior

It should give the value. It's working in .Net 7.

Basic Information

  • Version with issue: .Net 8
  • Last known good version: .Net 7
  • Platform Target Frameworks:
    • iOS: 17.4.1
  • Affected Devices: iPhone 15

Environment

Show/Hide Visual Studio info
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="SampleCarouselView.MainPage">

    <Grid HorizontalOptions="FillAndExpand"
                    VerticalOptions="FillAndExpand"
                    RowDefinitions="*, Auto">

        <CarouselView Grid.Row="0"
                        HorizontalOptions="FillAndExpand"
                        VerticalOptions="FillAndExpand"
                        ItemsSource="{Binding UserNames}"
                        x:Name="displayCarouselView">
            <CarouselView.ItemTemplate>
                <DataTemplate>
                    <StackLayout HorizontalOptions="FillAndExpand"
                                    VerticalOptions="FillAndExpand">
                        <Label Text="{Binding .}"
                                HorizontalOptions="FillAndExpand"
                                VerticalOptions="FillAndExpand"
                                HorizontalTextAlignment="Center"
                                VerticalTextAlignment="Center"
                                FontAttributes="Bold"
                                FontSize="Medium"
                                TextColor="Orange"
                                BackgroundColor="Black"/>
                    </StackLayout>
                </DataTemplate>
            </CarouselView.ItemTemplate>
        </CarouselView>

        <Button Text="Submit"
                Grid.Row="1"
                Clicked="Button_Clicked"
                Margin="20"
                CornerRadius="0"
                TextColor="Orange"
                BackgroundColor="Black"
                FontAttributes="Bold"
                FontSize="Medium"/>
    </Grid>

</ContentPage>


using System.Collections.ObjectModel;

namespace SampleCarouselView;

public partial class MainPage : ContentPage
{
    ObservableCollection<string> userNames;
    public ObservableCollection<string> UserNames
    {
        get => userNames;
        set
        {
            userNames = value;
            OnPropertyChanged(nameof(UserNames));
        }
    }

    public MainPage()
	{
		InitializeComponent();
        BindingContext = this;
        UserNames = new ObservableCollection<string>()
        {
            "User 1", "User 2", "User 3", "User 4", "User 5"
        };
    }

    void Button_Clicked(System.Object sender, System.EventArgs e)
    {
        Console.WriteLine("Before calling VisibleViews getter property");
        var list = displayCarouselView.VisibleViews.ToList()[0]; // Currently getting VisibleViews count as 0.
        Console.WriteLine("After calling VisibleViews getter property");
    }
}




@AmanGoyal009 AmanGoyal009 added s/unverified New report that has yet to be verified t/bug 🐛 labels Apr 17, 2024
@AmanGoyal009 AmanGoyal009 changed the title [Bug] In .Net 8 MAUI VisibleViews property not working [Bug] In .Net 8 MAUI VisibleViews property of CarouselView is not working Apr 17, 2024
@AmanGoyal009
Copy link
Author

Hello @radical , @shanselman, @michaeldwan , @paulbatum Can you guys please help me in this. As I am stuck due to this issue.

@jfversluis
Copy link
Member

This repository is for Xamarin.Forms. Please find the .NET MAUI repository here: https://github.com/dotnet/maui

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants