Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollectionView selecteditem background lost if collectionview (or parent) IsEnabled changed. #20615

Open
Toomas75 opened this issue Feb 15, 2024 · 12 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView i/regression This issue described a confirmed regression on a currently supported version migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@Toomas75
Copy link

Description

CollectionView selecteditem background lost if collectionview (or parent) IsEnabled changed. And buttons "ripple" effect still missing.

Steps to Reproduce

Run attached project -> click buttons.
MauiBug.zip

Link to public reproduction project repository

No response

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI, Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@Toomas75 Toomas75 added the t/bug Something isn't working label Feb 15, 2024
@Toomas75
Copy link
Author

Microsoft.Maui.Controls and Microsoft.Maui.Controls.Compatibility 8.0.10-nightly.10055

@Toomas75
Copy link
Author

`

<ContentPage.Resources>

    <ResourceDictionary>

        <Style TargetType="Grid">
            <Setter Property="VisualStateManager.VisualStateGroups">
                <VisualStateGroupList>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal" />
                        <VisualState x:Name="Selected">
                            <VisualState.Setters>
                                <Setter Property="BackgroundColor" Value="LightGreen" />
                            </VisualState.Setters>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateGroupList>
            </Setter>
        </Style>
    </ResourceDictionary>
</ContentPage.Resources>

<Grid x:Name="ParentGrid" RowDefinitions="Auto, *">
    <VerticalStackLayout Padding="10" Spacing="10">
        <Button Text="List.IsEnabled - selecteditem backround lost" Command="{Binding IsEnabledTriggerCmd}"></Button>
        <Button Text="List.IsEnabled - selecteditem backround lost" Command="{Binding ParentGridIsEnabledTriggerCmd}"></Button>

    </VerticalStackLayout>
    <CollectionView x:Name="List" Grid.Row="1" SelectionMode="Single" VerticalOptions="Start" SelectedItem="{Binding SelectedItemValue}" ItemsSource="{Binding Values}"  >
        
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Label Text="{Binding}" FontSize="Large"/>
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView> 
</Grid>

`

@Toomas75
Copy link
Author

`public partial class CollectionViewCurrentRow : ContentPage
{
public ICommand IsEnabledTriggerCmd { get; set; }
public ICommand ParentGridIsEnabledTriggerCmd { get; set; }
public object SelectedItemValue { get; set; }
public ArrayList Values { get; set; }
public CollectionViewCurrentRow()
{
//#20615
InitializeComponent();

	IsEnabledTriggerCmd = new Command(IsEnabledTriggerCmd_Executed);
	ParentGridIsEnabledTriggerCmd = new Command(ParentGridIsEnabledTriggerCmd_Executed);

	Values = ["First", "Second", "Third"];
	SelectedItemValue =Values[0]!;
	BindingContext = this;
}
private void IsEnabledTriggerCmd_Executed()
{
	List.IsEnabled = false;
	List.IsEnabled = true;
}
private void ParentGridIsEnabledTriggerCmd_Executed()
{
	ParentGrid.IsEnabled = false;
    ParentGrid.IsEnabled = true;
}

}`

@PureWeen PureWeen added platform/android 🤖 area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Feb 15, 2024
@PureWeen PureWeen added this to the Backlog milestone Feb 15, 2024
@ghost
Copy link

ghost commented Feb 15, 2024

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@Toomas75
Copy link
Author

This is major issue for us in big project.

https://github.com/dotnet/maui/issues/10595
https://github.com/dotnet/maui/issues/9523

@samhouts samhouts added potential-regression This issue described a possible regression on a currently supported version., verification pending migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Feb 20, 2024
@axa88
Copy link

axa88 commented Mar 17, 2024

It seems to me the issue is more basic. Where as any change effecting a CollectionView SelectedItem(s) VisualState will result in the View losing its Selected state Style

In this demonstration video attached, you can see simply changing the items VisualState to any of its other CommonStates, the Selected style will be lost when it should return to the Selected state.

Green = Selected
Orange = Focused,
Red = PointerOver

There of course needs to be a priority of VisualStates, to which only one can be active at once, but its only the Selected state which appears to not be reactivated when appropriate.

Selected.state.style.lost.mp4

Sadly , another simple yet seemingly misunderstood bug that might likely address loads of other reported issues if fixed
#10595
#13056
#13885
etc....

@Toomas75
Copy link
Author

@samhouts @PureWeen Please could you take another look at this. Easily testable. I also think fixing this will resolve lot of the issues.

@Toomas75
Copy link
Author

8.0.20-nightly.10336 - issue still persist

@Toomas75
Copy link
Author

8.0.40-nightly.10491 - no news.

@Toomas75
Copy link
Author

Toomas75 commented Jun 4, 2024

The same happens if collectionview is inside RefreshView and refreshview command CanExecute =false

@BeepBeepBopBop
Copy link

BeepBeepBopBop commented Jul 19, 2024

Hello, I would like to know if somebody found a workaround for this ? I am having nightmares trying to work with CollectionView on Windows... :( I am simply trying to be able to define Selected and Hovered background color but as discussed here the Selected visual state is lost everytime something happens like moving the cursor away from the selected item. Thanks for any help

@jaosnz-rep jaosnz-rep added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Aug 21, 2024
@jaosnz-rep
Copy link

jaosnz-rep commented Aug 22, 2024

I can repro this issue at android platform on the latest 17.12.0 Preview 1.0(8.0.80 & 8.0.3), but it can't be reproduced on .NET 7. It's a regression from .NET 7 to .NET 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView i/regression This issue described a confirmed regression on a currently supported version migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants