in src/BehaviorsSDKNative/Microsoft.Xaml.Interactions/IncrementalUpdateBehavior.cpp [158:204]
void IncrementalUpdateBehavior::IncrementalUpdater::OnContainerContentChanging(Windows::UI::Xaml::Controls::ListViewBase^ sender, ContainerContentChangingEventArgs^ e)
{
UIElement^ contentTemplateRoot = e->ItemContainer->ContentTemplateRoot;
if (_elementCache.find(contentTemplateRoot) == _elementCache.end())
{
return;
}
auto& elementCacheRecord = _elementCache[contentTemplateRoot];
if (!e->InRecycleQueue)
{
for (auto& phaseRecordPair : elementCacheRecord)
{
for (auto& phaseElementRecord : phaseRecordPair.second)
{
phaseElementRecord.FreezeAndHide();
}
}
if (elementCacheRecord.size() > 0)
{
e->RegisterUpdateCallback(elementCacheRecord.cbegin()->first, _cccCallbackHandler);
}
// set the DataContext manually since we inhibit default operation by setting e.Handled=true
FrameworkElement^ frameworkElement = dynamic_cast<FrameworkElement^>(contentTemplateRoot);
if (frameworkElement != nullptr)
{
frameworkElement->DataContext = e->Item;
}
}
else
{
// clear the DataContext manually since we inhibit default operation by setting e.Handled=true
contentTemplateRoot->ClearValue(FrameworkElement::DataContextProperty);
for (auto& phaseRecordPair : elementCacheRecord)
{
for (auto& phaseElementRecord : phaseRecordPair.second)
{
phaseElementRecord.ThawAndShow();
}
}
}
}