dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.74k forks source link

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

Open Toomas75 opened 8 months ago

Toomas75 commented 8 months ago

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 commented 8 months ago

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

Toomas75 commented 8 months ago

`<?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="MauiBug.CollectionViewCurrentRow" Title="CollectionViewCurrentRow">

`
Toomas75 commented 8 months ago

`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() { //https://github.com/dotnet/maui/issues/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;
}

}`

ghost commented 8 months ago

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 commented 8 months ago

This is major issue for us in big project.

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

axa88 commented 7 months ago

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.

https://github.com/dotnet/maui/assets/13371986/b6f61bb6-d0ba-421b-8d71-f12556e36cc5

Sadly , another simple yet seemingly misunderstood bug that might likely address loads of other reported issues if fixed https://github.com/dotnet/maui/issues/10595 https://github.com/dotnet/maui/issues/13056 https://github.com/dotnet/maui/issues/13885 etc....

Toomas75 commented 7 months ago

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

Toomas75 commented 7 months ago

8.0.20-nightly.10336 - issue still persist

Toomas75 commented 6 months ago

8.0.40-nightly.10491 - no news.

Toomas75 commented 5 months ago

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

BeepBeepBopBop commented 3 months ago

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 commented 2 months ago

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.