diff --git a/Sample/VirtualListViewSample/Section.cs b/Sample/VirtualListViewSample/Section.cs index 27d550e..69b84df 100644 --- a/Sample/VirtualListViewSample/Section.cs +++ b/Sample/VirtualListViewSample/Section.cs @@ -1,6 +1,20 @@ namespace VirtualListViewSample; -public class Section : List +public class Section : List { public string Title { get; set; } } + + +public class Item : BindableObject +{ + + public static readonly BindableProperty NameProperty = + BindableProperty.Create(nameof(Name), typeof(string), typeof(Item), string.Empty); + + public string Name + { + get => (string)GetValue(NameProperty); + set => SetValue(NameProperty, value); + } +} \ No newline at end of file diff --git a/Sample/VirtualListViewSample/SectionedAdapter.cs b/Sample/VirtualListViewSample/SectionedAdapter.cs index 5d10e11..1d971e8 100644 --- a/Sample/VirtualListViewSample/SectionedAdapter.cs +++ b/Sample/VirtualListViewSample/SectionedAdapter.cs @@ -2,7 +2,7 @@ namespace VirtualListViewSample; -public class SectionedAdapter : VirtualListViewAdapterBase +public class SectionedAdapter : VirtualListViewAdapterBase { public SectionedAdapter(IList
items) : base() { @@ -20,7 +20,7 @@ public override int GetNumberOfSections() public override int GetNumberOfItemsInSection(int sectionIndex) => Items[sectionIndex].Count; - public override string GetItem(int sectionIndex, int itemIndex) + public override Item GetItem(int sectionIndex, int itemIndex) => Items[sectionIndex][itemIndex]; public void AddItem(string sectionTitle, string itemName) @@ -33,7 +33,7 @@ public void AddItem(string sectionTitle, string itemName) Items.Add(section); } - section.Add(itemName); + section.Add(new Item { Name = itemName }); InvalidateData(); } @@ -51,4 +51,16 @@ public void RemoveItem(int sectionIndex, int itemIndex) InvalidateData(); } + + public void UpdateItem(int sectionIndex, int itemIndex) + { + var section = Items.ElementAtOrDefault(sectionIndex); + + if (section is null) + return; + + section[itemIndex].Name = $"{section[itemIndex].Name} Updated"; + + InvalidateItems(new ItemPosition(sectionIndex, itemIndex)); + } } \ No newline at end of file diff --git a/Sample/VirtualListViewSample/SectionedAdapterPage.xaml b/Sample/VirtualListViewSample/SectionedAdapterPage.xaml index f448b95..2465395 100644 --- a/Sample/VirtualListViewSample/SectionedAdapterPage.xaml +++ b/Sample/VirtualListViewSample/SectionedAdapterPage.xaml @@ -29,14 +29,19 @@ - - - + + + + +