Reputation: 1110
I am working on a Xamarin.Forms project and added a bool value to enable/disable the extra cells that show by default in ios.
My custom renderer is
public class CustomListView : ListView
{
public static readonly BindableProperty ShowExtraCellsProperty =
BindableProperty.Create("ShowExtraCells", typeof(bool), typeof(CustomListView), true);
public bool ShowExtraCells
{
get
{
return (bool)GetValue(ShowExtraCellsProperty);
}
set
{
SetValue(ShowExtraCellsProperty, value);
}
}
}
and my iOS renderer is
public class CustomListViewiOS : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
var listView = Control as UITableView;
listView.SeparatorInset = UIEdgeInsets.Zero;
this.Control.TableFooterView = new UIView();
}
}
}
my problem is I can't find the sender to cast it to the CustomListView to be able to get the value of the property.
Upvotes: 0
Views: 57
Reputation: 419
Please find Solution from here.
protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
var listView = Control as UITableView;
listView.SeparatorInset = UIEdgeInsets.Zero;
this.Control.TableFooterView = new UIView();
}
var element = (your Interface name here / Control which you want to render)this.Element;
//afterwards you can Access your Properties from **element** Like,
element.ShowExtraCells = true;
}
Upvotes: 1