Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Xamarin.Forms の ListView をコードビハインドで書く場合の例
Public partial class CodeBehindPage : ContentPage
{
ObservableCollection<Item> Items = new ObservableCollection<Item>();
public CodeBehindRamenPage()
{
InitializeComponent();
// Items初期化
this.Items.Clear();
// Binding対象にItemsを指定
listView.BindingContext = this.Items;
}
void AddButtonClick(object sender, EventArgs s)
{
this.Items.Add(new Item("MainText", "SubText", "SampleImage.png"));
}
void DeleteButtonClick(object sender, EventArgs s)
{
if (this.Items.Count > 0)
{
this.Items.Remove(this.Items[this.Items.Count - 1]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.