Ejemplo n.º 1
0
 internal ScrollTracingInfo(ScrollTracer tracer, int depth, FrameworkElement owner, VirtualizingStackPanel parent, object parentItem, int itemIndex)
 {
     ScrollTracer = tracer;
     Depth = depth;
     Owner = owner;
     Parent = parent;
     ParentItem = parentItem;
     ItemIndex = itemIndex;
 }
Ejemplo n.º 2
0
            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);
            }