private static bool ShouldIgnore(ScrollTraceOp op, ScrollTracingInfo sti) { return (op == ScrollTraceOp.NoOp); }
private void AddTrace(VirtualizingStackPanel vsp, ScrollTraceOp op, ScrollTracingInfo sti, params object[] args) { ScrollTraceRecord record = new ScrollTraceRecord(op, vsp, sti.Depth, sti.ItemIndex, _depth, BuildDetail(args)); _traceList.Add(record); switch (op) { default: break; case ScrollTraceOp.BeginMeasure: Push(); break; case ScrollTraceOp.EndMeasure: Pop(record); record.Snapshot = vsp.TakeSnapshot(); Flush(sti.Depth); break; case ScrollTraceOp.BeginArrange: Push(); break; case ScrollTraceOp.EndArrange: Pop(record); record.Snapshot = vsp.TakeSnapshot(); Flush(sti.Depth); break; case ScrollTraceOp.BSetAnchor: Push(); break; case ScrollTraceOp.ESetAnchor: Pop(record); break; case ScrollTraceOp.BOnAnchor: Push(); break; case ScrollTraceOp.ROnAnchor: Pop(record); break; case ScrollTraceOp.SOnAnchor: Pop(); break; case ScrollTraceOp.EOnAnchor: Pop(record); break; case ScrollTraceOp.RecycleChildren: case ScrollTraceOp.RemoveChildren: record.RevirtualizedChildren = args[2] as List<String>; break; } if (_flushDepth < 0) { Flush(_flushDepth); } }
internal static void ConfigureTracing(VirtualizingStackPanel vsp, DependencyObject itemsOwner, object parentItem, ItemsControl itemsControl) { Debug.Assert(!IsConfigured(vsp)); ScrollTracer tracer = null; if (itemsControl.Name == _targetName) { SetTarget(itemsControl, overwriteExistingTarget:false); } ScrollTracingInfo sti = _nullInfo; // default - do nothing if (parentItem == vsp) { // top level VSP if (itemsOwner == _target) { tracer = new ScrollTracer(itemsControl, vsp); } if (tracer != null) { sti = new ScrollTracingInfo(tracer, 0, itemsOwner as FrameworkElement, null, null, 0); } } else { // inner VSP VirtualizingStackPanel parent = VisualTreeHelper.GetParent(itemsOwner) as VirtualizingStackPanel; if (parent != null) { ScrollTracingInfo parentInfo = ScrollTracingInfoField.GetValue(parent); if (parentInfo != null) { tracer = parentInfo.ScrollTracer; if (tracer != null) { ItemContainerGenerator generator = parent.ItemContainerGenerator as ItemContainerGenerator; int itemIndex = (generator != null) ? generator.IndexFromContainer(itemsOwner, returnLocalIndex:true) : -1; sti = new ScrollTracingInfo(tracer, parentInfo.Depth + 1, itemsOwner as FrameworkElement, parent, parentItem, itemIndex); } } } } ScrollTracingInfoField.SetValue(vsp, sti); }