maui
maui copied to clipboard
[WinUI] .Net MAUI CollectionView with SelectionMode=Multiple shows tick marks without obvious way to remove them
Description
Selecting the first two items leads to the following graphical output:
Note the first two tick marks. I would love to remove them and use my own styling. Is that possible?
The tick mark is highlighted here:
Possibly relevant docs articles:
- https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/
- https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/selection
Steps to Reproduce
- Run the application https://github.com/MartyIX/MauiCollectionView202307/ on a Windows machine
- Click an item
-> I would like to change just style of the item and not to display any tick marks.
Link to public reproduction project repository
https://github.com/MartyIX/MauiCollectionView202307/
Version with bug
7.0.49
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 11 but I believe it's the same on Windows 10
Did you find any workaround?
No.
Relevant log output
No response
Are these tic boxes showing up only on Windows or Does it show up on Other Platforms Too? @MartyIX
@AathifMahir Hard for me to tell, it looks like this on macOS (maccatalyst):
and it does nothing. It seems like it's completely broken.
@AathifMahir Hard for me to tell, it looks like this on macOS (maccatalyst):
![]()
and it does nothing. It seems like it's completely broken.
Does nothing, Even moving the mouse over targets?
Yes
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.
I can confirm that I have the same problem and the same needs for my project.
I will track this issue. Thank you
In my case, I found a workaround that might be useful to someone else. I hid the checkboxes by overwriting the default maui style in Platforms/Windows/App.xaml. I specified the colours for the checkboxes to transparent and eliminated that space that is created at the beginning of each datagrid item by setting a different item presenter mode. Basically, I added the following lines of code:
<StaticResource x:Key="ListViewItemCheckBrush" ResourceKey="ControlAltFillColorTransparent" />
<StaticResource x:Key="ListViewItemCheckBoxBrush" ResourceKey="ControlAltFillColorTransparent" />
<ListViewItemPresenterCheckMode x:Key="ListViewItemCheckMode">Overlay</ListViewItemPresenterCheckMode>
In my case, I found a workaround that might be useful to someone else. I hid the checkboxes by overwriting the default maui style in Platforms/Windows/App.xaml. I specified the colours for the checkboxes to transparent and eliminated that space that is created at the beginning of each datagrid item by setting a different item presenter mode. Basically, I added the following lines of code:
<StaticResource x:Key="ListViewItemCheckBrush" ResourceKey="ControlAltFillColorTransparent" />
<StaticResource x:Key="ListViewItemCheckBoxBrush" ResourceKey="ControlAltFillColorTransparent" />
<ListViewItemPresenterCheckMode x:Key="ListViewItemCheckMode">Overlay</ListViewItemPresenterCheckMode>
@leonianto This worked wonderfully for me, thank you.
Verified this issue with Visual Studio Enterprise 17.9.0 Preview 4. Can repro on Windows platform with sample project. https://github.com/MartyIX/MauiCollectionView202307/
Hello. I had to customize the handler for CollectionView in order to hide the checkboxes that appear for Multi Selection on Windows. This worked for me. I hope this is helpful.
public class CustomCollectionViewHandler : CollectionViewHandler { public CustomCollectionViewHandler() { #if WINDOWS Mapper.AppendToMapping("IsMultiSelectCheckBoxEnabled", (handler, _) => handler.PlatformView.IsMultiSelectCheckBoxEnabled = false); #endif } }
And configure in MauiProgram.cs:
.ConfigureMauiHandlers( handlers => { handlers.AddHandler<CollectionView, CustomCollectionViewHandler>(); }
Some more info here
What @IsthisSid said but a bit shorter.
In MauiProgram.cs add:
#if WINDOWS
Microsoft.Maui.Controls.Handlers.Items.CollectionViewHandler.Mapper.AppendToMapping("DisableMultiselectCheckbox",
(handler, view) =>
{
handler.PlatformView.IsMultiSelectCheckBoxEnabled = false;
});
#endif
What @IsthisSid said but a bit shorter.
In MauiProgram.cs add:
#if WINDOWS Microsoft.Maui.Controls.Handlers.Items.CollectionViewHandler.Mapper.AppendToMapping("DisableMultiselectCheckbox", (handler, view) => { handler.PlatformView.IsMultiSelectCheckBoxEnabled = false; }); #endif
This worked perfectly. Thanks!