How to remove separator lines in Listview??

Hi,
How to remove separator lines in Listview??

Posts

  • DirkWeltzDirkWeltz DEMember ✭✭✭

    See https://forums.xamarin.com/discussion/22056/listview-item-bug, found by a quick search, or use Xamarin.Forms.Labs ExtendedViewCell https://github.com/XForms/Xamarin-Forms-Labs. There you could see how to do it on the different platforms.

  • DevinRoseDevinRose USMember ✭✭

    For iOS, you can make a custom renderer that removes/hides the separator lines: https://forums.xamarin.com/discussion/comment/74497/

  • Ruchi.1451Ruchi.1451 USMember ✭✭

    Hi,
    I make it work by using ViewCellRenderer.

    [assembly: ExportRendererAttribute(typeof(ToDoItemCell), typeof(TaxComp.iOS.ViewCellRenderer))] namespace TaxComp.iOS { public class ViewCellRenderer:Xamarin.Forms.Platform.iOS.ViewCellRenderer { public override MonoTouch.UIKit.UITableViewCell GetCell (Cell item, MonoTouch.UIKit.UITableView tv) { tv.SeparatorColor = UIColor.Clear; tv.SeparatorStyle = UITableViewCellSeparatorStyle.DoubleLineEtched; return base.GetCell (item, tv); } } }

  • ShameelShameel INMember ✭✭

    Hi Ruchi,I am new in Xamarin, please share more of your code, in particular the custom renderer code in iOS and the code in Xamarin Forms that shows your ViewCell derived class.

  • Ruchi.1451Ruchi.1451 USMember ✭✭
    edited October 2014

    Hi @Shameel.kt‌ . Below is code of custom view cell in xamarin forms that we will use for ListView

    public class ToDoItemCell:ViewCell { public ToDoItemCell () { } }

    And this is the renderer we will make in iOS project.

    [assembly: ExportRendererAttribute(typeof(ToDoItemCell), typeof(TaxComp.iOS.ViewCellRenderer))] namespace TaxComp.iOS { public class ViewCellRenderer:Xamarin.Forms.Platform.iOS.ViewCellRenderer { public override MonoTouch.UIKit.UITableViewCell GetCell (Cell item, MonoTouch.UIKit.UITableView tv) { tv.SeparatorColor = UIColor.Clear; tv.SeparatorStyle = UITableViewCellSeparatorStyle.DoubleLineEtched; return base.GetCell (item, tv); } } }

  • ShameelShameel INMember ✭✭

    @Ruchi.1451‌ :Thanks for your support! I will try to implement this.

  • JorisMeylaersJorisMeylaers USMember ✭✭

    Is there a way to do this in xaml?

  • JorisMeylaersJorisMeylaers USMember ✭✭

    @VinayakGawas
    Thanks! Is there a way to hide it for empty cells?
    Now, there will be useless horizontal lines if I have an empty list

  • VinayakGawasVinayakGawas USMember ✭✭✭
    edited March 2017

    @JorisMeylaers You can control that in your ViewModel. Don't add empty objects in your ListView.

  • y_SBSICy_SBSIC USMember ✭✭✭

    Thanks neroware

  • SilvanoPaxiaSilvanoPaxia ITMember ✭✭
    edited March 2017

    How can I avoid the selection highlight to overlap bottom and top of cell borders? An image inside the cell (even if expanded to the full extent of its parent cell) will get an ugly highlight border (about 1pt) around it when tapped on iOS...

  • TonSnoeiTonSnoei NLMember ✭✭

    @VinayakGawas said:
    @JorisMeylaers Yes put

    SeparatorVisibility="None" in xaml ListViewAttributes

    The right answer!

  • CeregolCeregol USMember ✭✭
    edited November 2017

    This is my solution, it worked for me.

        public MenuListView()
        {
            List<MenuItem> data = new MenuListData();
            ItemsSource = data;
            VerticalOptions = LayoutOptions.FillAndExpand;
            //Color!
            BackgroundColor = Color.White;
         **   SeparatorColor = Color.White;**
            var cell = new DataTemplate(typeof(ImageCell));
    
             cell.SetBinding(TextCell.TextProperty, "Title");
    
            cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");
    
            ItemTemplate = cell;
            SelectedItem = data[0];
        }
    
  • ioroikoioroiko Member

    SeparatorVisibility="None" perfectly works! Thank you!

Sign In or Register to comment.