Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / VirtualizingPanel.cs / 1305600 / VirtualizingPanel.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using MS.Internal;
using MS.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows.Media;
using System.Windows.Controls.Primitives; // IItemContainerGenerator
namespace System.Windows.Controls
{
///
/// A base class that provides access to information that is useful for panels that with to implement virtualization.
///
public abstract class VirtualizingPanel : Panel
{
///
/// The default constructor.
///
protected VirtualizingPanel() : base()
{
}
///
/// The generator associated with this panel.
///
public IItemContainerGenerator ItemContainerGenerator
{
get
{
return Generator;
}
}
internal override void GenerateChildren()
{
// Do nothing. Subclasses will use the exposed generator to generate children.
}
///
/// Adds a child to the InternalChildren collection.
/// This method is meant to be used when a virtualizing panel
/// generates a new child. This method circumvents some validation
/// that occurs in UIElementCollection.Add.
///
/// Child to add.
protected void AddInternalChild(UIElement child)
{
AddInternalChild(InternalChildren, child);
}
///
/// Inserts a child into the InternalChildren collection.
/// This method is meant to be used when a virtualizing panel
/// generates a new child. This method circumvents some validation
/// that occurs in UIElementCollection.Insert.
///
/// The index at which to insert the child.
/// Child to insert.
protected void InsertInternalChild(int index, UIElement child)
{
InsertInternalChild(InternalChildren, index, child);
}
///
/// Removes a child from the InternalChildren collection.
/// This method is meant to be used when a virtualizing panel
/// re-virtualizes a new child. This method circumvents some validation
/// that occurs in UIElementCollection.RemoveRange.
///
///
///
protected void RemoveInternalChildRange(int index, int range)
{
RemoveInternalChildRange(InternalChildren, index, range);
}
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly)
internal static void AddInternalChild(UIElementCollection children, UIElement child)
{
children.AddInternal(child);
}
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly)
internal static void InsertInternalChild(UIElementCollection children, int index, UIElement child)
{
children.InsertInternal(index, child);
}
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly)
internal static void RemoveInternalChildRange(UIElementCollection children, int index, int range)
{
children.RemoveRangeInternal(index, range);
}
///
/// Called when the Items collection associated with the containing ItemsControl changes.
///
/// sender
/// Event arguments
protected virtual void OnItemsChanged(object sender, ItemsChangedEventArgs args)
{
}
///
/// Called when the UI collection of children is cleared by the base Panel class.
///
protected virtual void OnClearChildren()
{
}
///
/// Generates the item at the specified index and calls BringIntoView on it.
///
/// Specify the item index that should become visible
protected internal virtual void BringIndexIntoView(int index)
{
}
internal override void OnItemsChangedInternal(object sender, ItemsChangedEventArgs args)
{
switch (args.Action)
{
case NotifyCollectionChangedAction.Add:
case NotifyCollectionChangedAction.Remove:
case NotifyCollectionChangedAction.Replace:
case NotifyCollectionChangedAction.Move:
// Don't allow Panel's code to run for add/remove/replace/move
break;
default:
base.OnItemsChangedInternal(sender, args);
break;
}
OnItemsChanged(sender, args);
}
internal override void OnClearChildrenInternal()
{
OnClearChildren();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using MS.Internal;
using MS.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows.Media;
using System.Windows.Controls.Primitives; // IItemContainerGenerator
namespace System.Windows.Controls
{
///
/// A base class that provides access to information that is useful for panels that with to implement virtualization.
///
public abstract class VirtualizingPanel : Panel
{
///
/// The default constructor.
///
protected VirtualizingPanel() : base()
{
}
///
/// The generator associated with this panel.
///
public IItemContainerGenerator ItemContainerGenerator
{
get
{
return Generator;
}
}
internal override void GenerateChildren()
{
// Do nothing. Subclasses will use the exposed generator to generate children.
}
///
/// Adds a child to the InternalChildren collection.
/// This method is meant to be used when a virtualizing panel
/// generates a new child. This method circumvents some validation
/// that occurs in UIElementCollection.Add.
///
/// Child to add.
protected void AddInternalChild(UIElement child)
{
AddInternalChild(InternalChildren, child);
}
///
/// Inserts a child into the InternalChildren collection.
/// This method is meant to be used when a virtualizing panel
/// generates a new child. This method circumvents some validation
/// that occurs in UIElementCollection.Insert.
///
/// The index at which to insert the child.
/// Child to insert.
protected void InsertInternalChild(int index, UIElement child)
{
InsertInternalChild(InternalChildren, index, child);
}
///
/// Removes a child from the InternalChildren collection.
/// This method is meant to be used when a virtualizing panel
/// re-virtualizes a new child. This method circumvents some validation
/// that occurs in UIElementCollection.RemoveRange.
///
///
///
protected void RemoveInternalChildRange(int index, int range)
{
RemoveInternalChildRange(InternalChildren, index, range);
}
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly)
internal static void AddInternalChild(UIElementCollection children, UIElement child)
{
children.AddInternal(child);
}
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly)
internal static void InsertInternalChild(UIElementCollection children, int index, UIElement child)
{
children.InsertInternal(index, child);
}
// This is internal as an optimization for VirtualizingStackPanel (so it doesn't need to re-query InternalChildren repeatedly)
internal static void RemoveInternalChildRange(UIElementCollection children, int index, int range)
{
children.RemoveRangeInternal(index, range);
}
///
/// Called when the Items collection associated with the containing ItemsControl changes.
///
/// sender
/// Event arguments
protected virtual void OnItemsChanged(object sender, ItemsChangedEventArgs args)
{
}
///
/// Called when the UI collection of children is cleared by the base Panel class.
///
protected virtual void OnClearChildren()
{
}
///
/// Generates the item at the specified index and calls BringIntoView on it.
///
/// Specify the item index that should become visible
protected internal virtual void BringIndexIntoView(int index)
{
}
internal override void OnItemsChangedInternal(object sender, ItemsChangedEventArgs args)
{
switch (args.Action)
{
case NotifyCollectionChangedAction.Add:
case NotifyCollectionChangedAction.Remove:
case NotifyCollectionChangedAction.Replace:
case NotifyCollectionChangedAction.Move:
// Don't allow Panel's code to run for add/remove/replace/move
break;
default:
base.OnItemsChangedInternal(sender, args);
break;
}
OnItemsChanged(sender, args);
}
internal override void OnClearChildrenInternal()
{
OnClearChildren();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientScriptItem.cs
- SqlEnums.cs
- PeerNameResolver.cs
- ScriptingWebServicesSectionGroup.cs
- CodeIndexerExpression.cs
- EncryptedKeyIdentifierClause.cs
- BindingGroup.cs
- ControlIdConverter.cs
- XmlQueryRuntime.cs
- TCPClient.cs
- Events.cs
- HttpCapabilitiesEvaluator.cs
- StopRoutingHandler.cs
- ToolStripCodeDomSerializer.cs
- XmlSchemaInclude.cs
- FixedDocumentSequencePaginator.cs
- AuthorizationSection.cs
- SQLResource.cs
- CheckBoxStandardAdapter.cs
- ServiceChannelManager.cs
- OptimalTextSource.cs
- ObjectItemAttributeAssemblyLoader.cs
- Message.cs
- FontFamily.cs
- DataSourceDesigner.cs
- DependencyObjectType.cs
- XmlReflectionMember.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- TrackingProvider.cs
- ListItemViewAttribute.cs
- httpapplicationstate.cs
- QuotedStringWriteStateInfo.cs
- Int16Storage.cs
- MenuAdapter.cs
- AllMembershipCondition.cs
- ThousandthOfEmRealDoubles.cs
- ByteStreamGeometryContext.cs
- RSAPKCS1SignatureFormatter.cs
- Run.cs
- DiagnosticTraceRecords.cs
- HttpGetClientProtocol.cs
- TableChangeProcessor.cs
- EventDriven.cs
- PropertyBuilder.cs
- ActivityDesignerAccessibleObject.cs
- EnumerableRowCollection.cs
- WebPartsPersonalizationAuthorization.cs
- TextTreeDeleteContentUndoUnit.cs
- BitmapCache.cs
- RoleGroupCollection.cs
- LogicalTreeHelper.cs
- JoinCqlBlock.cs
- _SSPIWrapper.cs
- SendMailErrorEventArgs.cs
- Attribute.cs
- DodSequenceMerge.cs
- Win32Exception.cs
- XsltArgumentList.cs
- GeometryHitTestResult.cs
- _TransmitFileOverlappedAsyncResult.cs
- PowerStatus.cs
- AxisAngleRotation3D.cs
- QilCloneVisitor.cs
- BooleanAnimationUsingKeyFrames.cs
- Rect3DConverter.cs
- GeneralTransform3DGroup.cs
- ImplicitInputBrush.cs
- SQLUtility.cs
- CroppedBitmap.cs
- CallSiteHelpers.cs
- RSAPKCS1SignatureDeformatter.cs
- PriorityItem.cs
- ConstructorArgumentAttribute.cs
- FieldAccessException.cs
- SchemaSetCompiler.cs
- KeyValueSerializer.cs
- ParameterInfo.cs
- SqlDataSourceStatusEventArgs.cs
- EmptyCollection.cs
- oledbmetadatacolumnnames.cs
- PointCollection.cs
- LineSegment.cs
- DesignerLabelAdapter.cs
- BCLDebug.cs
- Script.cs
- RelatedCurrencyManager.cs
- UserControl.cs
- SqlErrorCollection.cs
- CharEnumerator.cs
- XamlTemplateSerializer.cs
- QueryParameter.cs
- PrivilegedConfigurationManager.cs
- ContentControl.cs
- TimerElapsedEvenArgs.cs
- GridErrorDlg.cs
- TextElementEnumerator.cs
- M3DUtil.cs
- MyContact.cs
- PointLightBase.cs
- ObjectDataSourceEventArgs.cs