Description
Based on my other bug #19768 (which may be related) I tried to make a workaround to change InputTransparent and Opacity to "fake" IsEnabled=false, I immediately ran into more issues.
After making this test I found inconsistent results of how a CollectionView performs based on if I set IsEnabled, InputTransparent and Opacity via xaml styles or via code.
The linked example works like so:
Top left - Binds IsEnabled="{Binding IsCollectionViewEnabled}"
Top right - Binds IsEnabled="{Binding IsCollectionViewEnabled}" but also has the AutoInputTransparent style.
Bottom left - In the backing code (not via binding) it sets IsEnabled to true/false depending on the button pushed.
Bottom right - n the backing code (not via binding) it sets Opacity and InputTransparent to 0.5/true and 1.0/false depending on the depending on the button pushed.
In a perfect world if you hit the top row in every CollectionView you will see it select. If you hit the IsEnabled=False button then every CollectionView should go into a disabled like state. Clicking a different item in the CollectionView should not select it. Clicking the IsEnabled=True button should now re-enable every CollectionView and allow you to select another item in the CollectionView.
What actually happens is on clicking IsEnabled=False button
- top left and bottom left CollectionViews go into a disabled looking state (text colour changes) but clicking another row will select it (reminder: these are the two that use
IsEnabled explicitly in the binding or in the code behind.
- top right and bottom right CollectionViews go into a disabled looking state and can not be interacted with any further (reminder: these are the two that use
Opacity and InputTransparent to fake being disabled).
When re-enabling the CollectionViews with the IsEnabled=True button
- top left and bottom left text color changes back to an enabled state.
- top right can no longer be interacted with (almost like
InputTransparent didn't toggle back)
- bottom right goes back to a fully enabled state.
Summary: Bottom right CollectionView is the only one that works as expected.
EDIT: If the following is added to the MainPageModel.cs
[ObservableProperty]
bool isInputTransparent = false;
[ObservableProperty]
double opacity = 1.0;
changing the binding of the top right CollectionView to use InputTransparent="{Binding IsInputTransparent}" Opacity="{Binding Opacity}" and not use IsEnabled or Style it will behave the same as the CollectionView in the bottom right.
My take-away with that is that using a Style does not make it behave odd, however using IsEnabled + InputTransparent(style) + Opacity(style) is causing some bugs to happen.
EDIT 2:
Adding the following VisualStates to the top right collection view (removing any style, keeping IsEnabled binding)
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="Opacity" Value="1.0" />
<Setter Property="InputTransparent" Value="false" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Opacity" Value="0.5" />
<Setter Property="InputTransparent" Value="true" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
it seems to perform the same as the bottom right CollectionView. To me this seems to indicate using a Style or using a VisualState is behaving differently even though the properties being set are identical. I don't know why these would differ, some race condition maybe?
Steps to Reproduce
- Create MAUI application
- Add CollectionView
- Try disable it with IsEnabled=false or InputTransparent=true+Opacity=0.5
Link to public reproduction project repository
https://github.com/beeradmoore/maui-issue-CollectionViewInputTransparentTest
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, macOS
Affected platform versions
iOS 17.2.1, macOS 14.2.1, Android 13
Did you find any workaround?
No
Relevant log output
No response
Description
Based on my other bug #19768 (which may be related) I tried to make a workaround to change
InputTransparentandOpacityto "fake"IsEnabled=false, I immediately ran into more issues.After making this test I found inconsistent results of how a
CollectionViewperforms based on if I setIsEnabled,InputTransparentandOpacityvia xaml styles or via code.The linked example works like so:
Top left - Binds
IsEnabled="{Binding IsCollectionViewEnabled}"Top right - Binds
IsEnabled="{Binding IsCollectionViewEnabled}"but also has theAutoInputTransparentstyle.Bottom left - In the backing code (not via binding) it sets
IsEnabledto true/false depending on the button pushed.Bottom right - n the backing code (not via binding) it sets
OpacityandInputTransparentto 0.5/true and 1.0/false depending on the depending on the button pushed.In a perfect world if you hit the top row in every CollectionView you will see it select. If you hit the
IsEnabled=Falsebutton then every CollectionView should go into a disabled like state. Clicking a different item in the CollectionView should not select it. Clicking theIsEnabled=Truebutton should now re-enable every CollectionView and allow you to select another item in the CollectionView.What actually happens is on clicking
IsEnabled=FalsebuttonIsEnabledexplicitly in the binding or in the code behind.OpacityandInputTransparentto fake being disabled).When re-enabling the CollectionViews with the
IsEnabled=TruebuttonInputTransparentdidn't toggle back)Summary: Bottom right CollectionView is the only one that works as expected.
EDIT: If the following is added to the
MainPageModel.cschanging the binding of the top right CollectionView to use
InputTransparent="{Binding IsInputTransparent}" Opacity="{Binding Opacity}"and not useIsEnabledorStyleit will behave the same as the CollectionView in the bottom right.My take-away with that is that using a Style does not make it behave odd, however using IsEnabled + InputTransparent(style) + Opacity(style) is causing some bugs to happen.
EDIT 2:
Adding the following VisualStates to the top right collection view (removing any style, keeping IsEnabled binding)
it seems to perform the same as the bottom right CollectionView. To me this seems to indicate using a Style or using a VisualState is behaving differently even though the properties being set are identical. I don't know why these would differ, some race condition maybe?
Steps to Reproduce
Link to public reproduction project repository
https://github.com/beeradmoore/maui-issue-CollectionViewInputTransparentTest
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, macOS
Affected platform versions
iOS 17.2.1, macOS 14.2.1, Android 13
Did you find any workaround?
No
Relevant log output
No response