From 0086b17854db1245fd9b660d38d1cf7ce688b40d Mon Sep 17 00:00:00 2001 From: vczh Date: Tue, 26 Dec 2023 21:02:25 -0800 Subject: [PATCH] Use BindableListView.NotifyItemDataModified in tutorial to improve performance --- Tutorial/GacUI_Controls/AddressBook/Main.cpp | 6 ------ Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml | 5 +++++ .../AddressBook/UI/Source/DemoPartialClasses.cpp | 4 ++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Tutorial/GacUI_Controls/AddressBook/Main.cpp b/Tutorial/GacUI_Controls/AddressBook/Main.cpp index 3c090e1f..34135695 100644 --- a/Tutorial/GacUI_Controls/AddressBook/Main.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/Main.cpp @@ -122,12 +122,6 @@ public: birthday = _birthday; phone = _phone; address = _address; - - vint index = category->contacts.IndexOf(this); - if (index != -1) - { - category->contacts.NotifyUpdate(index, 1); - } } }; diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml index df95882d..4b3854b3 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Resource.xml @@ -160,6 +160,11 @@ window.MoveToScreenCenter(); window.SetContact(ViewModel.SelectedContact); $Await window.ShowModalAsync(self); + + if (window.Ready) + { + listViewContacts.NotifyItemDataModified(listViewContacts.SelectedItemIndex, 1); + } delete window; } ]]> diff --git a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp index a2a4e2d4..77b781b8 100644 --- a/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_Controls/AddressBook/UI/Source/DemoPartialClasses.cpp @@ -1378,6 +1378,10 @@ Closures throw ::vl::Exception(::vl::__vwsn::This(::vl::__vwsn::This(__vwsn_co_result_.Obj())->GetFailure().Obj())->GetMessage()); } } + if (::vl::__vwsn::This(__vwsn_co0_window)->Ready) + { + ::vl::__vwsn::This(__vwsnthis_0->listViewContacts)->NotifyItemDataModified(::vl::__vwsn::This(__vwsnthis_0->listViewContacts)->GetSelectedItemIndex(), static_cast<::vl::vint>(1)); + } ::vl::__vwsn::This(__vwsn_co0_window)->Dispose(true); this->SetStatus(::vl::reflection::description::CoroutineStatus::Stopped); return;