maui icon indicating copy to clipboard operation
maui copied to clipboard

[WinUI] .Net MAUI CollectionView with SelectionMode=Multiple shows tick marks without obvious way to remove them

Open MartyIX opened this issue 1 year ago • 12 comments

Description

Selecting the first two items leads to the following graphical output:

image

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:

image

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

  1. Run the application https://github.com/MartyIX/MauiCollectionView202307/ on a Windows machine
  2. 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

MartyIX avatar Jul 10 '23 14:07 MartyIX

Are these tic boxes showing up only on Windows or Does it show up on Other Platforms Too? @MartyIX

AathifMahir avatar Jul 10 '23 14:07 AathifMahir

@AathifMahir Hard for me to tell, it looks like this on macOS (maccatalyst):

image

and it does nothing. It seems like it's completely broken.

MartyIX avatar Jul 10 '23 15:07 MartyIX

@AathifMahir Hard for me to tell, it looks like this on macOS (maccatalyst):

image

and it does nothing. It seems like it's completely broken.

Does nothing, Even moving the mouse over targets?

AathifMahir avatar Jul 10 '23 15:07 AathifMahir

Yes

MartyIX avatar Jul 10 '23 15:07 MartyIX

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.

ghost avatar Jul 11 '23 18:07 ghost

I can confirm that I have the same problem and the same needs for my project.

image

I will track this issue. Thank you

leonianto avatar Jul 14 '23 14:07 leonianto

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 avatar Oct 03 '23 12:10 leonianto

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.

tschbc avatar Jan 22 '24 18:01 tschbc

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/

QianaJiao avatar Jan 30 '24 06:01 QianaJiao

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

IsthisSid avatar Jan 30 '24 20:01 IsthisSid

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

GuidoNeele avatar Apr 16 '24 08:04 GuidoNeele

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!

DatenThielt avatar May 03 '24 21:05 DatenThielt