maui: CollectionView does not select an element with a Frame as DataTemplate
Description
When you have a selection mode other than None, and a DataTemplate with a Frame, it is not possible to select one of the elements by clicking on the content of the frame, only outside the Frame control.
Steps to Reproduce
1.- Create a new .NET MAUI project. 2.- Remove default content. 3.- In the XAML file:
<CollectionView SelectionMode="Single">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>mono</x:String>
<x:String>monodroid</x:String>
<x:String>monotouch</x:String>
<x:String>monorail</x:String>
<x:String>monodevelop</x:String>
<x:String>monotone</x:String>
<x:String>monopoly</x:String>
<x:String>monomodal</x:String>
<x:String>mononucleosis</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame Margin="5">
<Label Text="{Binding .}" />
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Test the application.
5.- Try to select an element, and see that it is only possible to do it by clicking outside the Frame border.

Version with bug
6.0.400 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 10
Did you find any workaround?
The selection occurs well without a Data Template.
Relevant log output
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 8
- Comments: 18
The workaround for this is to use Border. Perhaps MSFT should add the [Obsolete] attribute so that future developers are aware about this issue? Thanks to @myrup for this workaround.
This issue hasn’t seen any progress. If Frame is deprecated (MSDN documentation mentions it is), it should be clearly identified as such in the code with the [Obsolete] attribute with a message stating to only use in older Xamarin applications, and referencing Border as the preferred control.
I just spent the morning trying to determine why a simple command wasn’t firing when tapping on the content. I accidentally clicked in the corner region and realized it was the Frame content which brought me here. This is a pretty big waste of time for a known bug related to a core component of the .NET MAUI framework.
Frameis apparently there for legacy reasons. Consider usingBorderinstead (untested).Using Border worked for android. But not working on Mac. Is there any workaround for mac? –Update I tried again, I found out that i have hold the click for atleast 3 seconds in order to change the selection.
We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.