Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When using a ListView with CachingStrategy "RecycleElement" I can't set the native cells selectionstyle to none using a ViewCellRenderer.
So for example I do this:
[assembly: ExportRenderer(typeof(ViewCell), typeof(ExtViewCellRenderer))]
public class ExtViewCellRenderer : ViewCellRenderer
public override UIKit.UITableViewCell GetCell(Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
var cell = base.GetCell(item, reusableCell, tv);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
Now it will still display the gray selection box when selecting it.
After looking through the Xamarin.Forms source code I found the following code in file:
internal static UITableViewCell GetNativeCell(UITableView tableView, Cell cell, bool recycleCells = false, string templateId = "")
var id = cell.GetType().FullName;
var renderer = (CellRenderer)Registrar.Registered.GetHandler(cell.GetType());
ContextActionsCell contextCell = null;
UITableViewCell reusableCell = null;
if (cell.HasContextActions || recycleCells)
In this method a new cell, a "context action cell" is created if recycle cells is enabled. This will basically create a new native cell which will use the default cell selection value, this makes my change in the ViewCellRenderer have no effect since that is not the actual cell used. Instead my original cell is used inside this context cell which probably causes this bug. So we need a way of the context cell to copy properties form it's containing native cell.
Let me run the code in comment 0 to try confirming this issue. In the meantime, can you let me know what version of Forms this previously worked on? Thanks!
Hmm I wish I knew, I think it might have been like this for a long time... probably since context cells was introduced?
Created attachment 20047 [details]
I was able to reproduce the issue with the attached repro project. I tested with the following versions:
Forms 2.3.4-pre2 - BAD
Forms 188.8.131.52 - BAD
Forms 184.108.40.206 - BAD
As mentioned in the description, the issue does seem to be that the SelectionStyle set in the custom ViewCell renderer is overridden later inside CellTableViewCell.GetNativeCell: https://github.com/xamarin/Xamarin.Forms/blob/2.3.3/Xamarin.Forms.Platform.iOS/Cells/CellTableViewCell.cs#L89
### Steps to Reproduce
1. Run the attached project
2. Select a cell
#### Expected Results
The cell will _not_ be highlighted
### Actual Results
The cell is highlighted with a grey color
Confirmed this is still the case on 220.127.116.11-nightly. Also confirmed Xamarin.iOS behaves correctly.
Seems to work with RetainElement only.
Elevating the priority.
Should be fixed on 2.3.6.-pre1