Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Can't make ViewCellRenderer work

$
0
0

Hello!

So, what I'm trying to do is to disable selection style on every ViewCell. I created my own ViewCellRenderer, but the only thing I can see when I run the app (iOS) are generic ViewCells, and my code it'n never called.

Someone knows what am I doing wrong?

XAML

        <ListView>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            {my cell XAML here}
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

CellRenderer.cs

    [assembly: ExportRenderer(typeof(ViewCell), typeof(CellRenderer))]
    namespace n
    {
        public class CellRenderer : ViewCellRenderer
        {
            public override UITableViewCell GetCell(Cell item, UITableView tv)
            {
                var cell = base.GetCell(item, tv);

                if (cell != null)
                    cell.SelectionStyle = UITableViewCellSelectionStyle.None;

                return cell;
            }
        }
    }

Result

Thanks!
Juli


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>