Created
September 11, 2016 03:19
-
-
Save ytabuchi/199f9fef435e29a434ee8c872c267281 to your computer and use it in GitHub Desktop.
Xamarin.Forms の ListView をコードビハインドで書く場合の例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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