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

ListView default Selected Item background Color is not working

$
0
0

I am using ListView with CustomCell (Custom Renderer) for iOS. I am able to change the color of the background when the user taps on the listviewItem(or when the item is highlighted).

// Custom Cell background
public override UIKit.UITableViewCell GetCell (Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
{
var cell = base.GetCell(item, reusableCell, tv);

        cell.BackgroundColor = UIKit.UIColor.Black;
        cell.TextLabel.TextColor = UIKit.UIColor.White;

        if (bgView == null)
        {
            bgView = new UIView(cell.SelectedBackgroundView.Bounds);
            bgView.Layer.BackgroundColor = UIColor.FromRGB (238, 238, 238).CGColor;
            bgView.Layer.BorderColor = UIColor.FromRGB (238, 238, 238).CGColor;
            bgView.Layer.BorderWidth = 1.0f;


        }

        cell.SelectedBackgroundView = bgView;

        return cell;
    }

But the background of the color of cell is not changing for default Selected Item

listView.SelectedItem = 2; //background Color or Highlighting is not happening

Any suggestions?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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