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

Custom UITableView in my custom ListViewRenderer?

$
0
0

I want to remove the top and bottom horizontal lines that show up when a user selects an item in my listview. I don't think I can do it from Forms proper, but I already have created my own ListView-derived class and a custom renderer in iOS (to remove the separator lines between items).

To remove those selected item lines on the top and bottom of the item, I have read on iOS forums I need to either set:

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

in some function called cellForRowAtIndexPath

or override(?) this function and return false:

    tableView:shouldHighlightRowAtIndexPath:

Either way I think I need to create a UITableView derived class and make my ListViewRenderer use that instead of the default one. But I don't know how to do that.

This is my renderer. See that I can get the UITableView via the Control property of the renderer, but it is the standard table view, so I cannot override the above methods.

/// <summary>
/// Custom renderer for our list view so we can remove the separator lines between each item
/// </summary>
public class SeparatorlessListViewRenderer : ListViewRenderer
{
    protected override void OnElementChanged (ElementChangedEventArgs<ListView> e)
    {
        base.OnElementChanged (e);

        var tableView = Control as UITableView;
        tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
        tableView.SeparatorColor = UIColor.Clear;
    }
}

Any ideas?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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