主にプログラミング関連のメモ帳 ♪(✿╹ヮ╹)ノ
書いてあるコードは自己責任でご自由にどうぞ。記事本文の無断転載は禁止です。
2015/12/17
なんともタイトルだけだと、何が言いたいのかわかりづらいですが、
ListView を使った際、アイテム数が少ない場合は、下の方に空のセルが詰められます。
↓ こんな感じです(一番下が空のセル)
個人的に気持ち悪いので、これを消し去ります。
検索したら出てきました。
How to hide the empty rows of a list view in xamrin.forms in ios - Xamarin Forums
しかし、できません。
なので、とりあえず同様の動作をするコードを作りました。
[assembly: ExportRenderer(typeof(ListView), typeof(iOSListViewRenderer))]
namespace BlankCell.iOS.Renderers
{
public class iOSListViewRenderer : ListViewRenderer
{
public iOSListViewRenderer()
{
this.ElementChanged += (sender, e) =>
{
var element = this.Element as ListView;
if (element == null)
{
return;
}
element.Footer = new ContentView();
};
}
}
}
これでできます。