Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / DescendentsWalkerBase.cs / 2 / DescendentsWalkerBase.cs
using System; using System.Collections; using System.Diagnostics; using System.Windows; using System.Windows.Media; using MS.Utility; namespace System.Windows { ////// This is a base class to the DescendentsWalker. It is factored out so that /// FrameworkContextData can store and retrieve it from context local storage /// in a type agnostic manner. /// internal class DescendentsWalkerBase { #region Construction protected DescendentsWalkerBase(TreeWalkPriority priority) { _startNode = null; _priority = priority; _recursionDepth = 0; _nodes = new FrugalStructList(); } #endregion Construction internal bool WasVisited(DependencyObject d) { DependencyObject ancestor = d; while ((ancestor != _startNode) && (ancestor != null)) { DependencyObject logicalParent; if (FrameworkElement.DType.IsInstanceOfType(ancestor)) { FrameworkElement fe = ancestor as FrameworkElement; logicalParent = fe.Parent; // FrameworkElement DependencyObject dependencyObjectParent = VisualTreeHelper.GetParent(fe); if (dependencyObjectParent != null && logicalParent != null && dependencyObjectParent != logicalParent) { return _nodes.Contains(ancestor); } // Follow visual tree if not null otherwise we follow logical tree if (dependencyObjectParent != null) { ancestor = dependencyObjectParent; continue; } } else { // FrameworkContentElement FrameworkContentElement ancestorFCE = ancestor as FrameworkContentElement; logicalParent = (ancestorFCE != null) ? ancestorFCE.Parent : null; } ancestor = logicalParent; } return (ancestor != null); } internal DependencyObject _startNode; internal TreeWalkPriority _priority; internal FrugalStructList _nodes; internal int _recursionDepth; internal const int MAX_TREE_DEPTH = 250; } /// /// Enum specifying whether visual tree needs /// to be travesed first or the logical tree /// internal enum TreeWalkPriority { ////// Traverse Logical Tree first /// LogicalTree, ////// Traverse Visual Tree first /// VisualTree } } // 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
- RequestNavigateEventArgs.cs
- StylusEventArgs.cs
- DateTimePicker.cs
- MenuStrip.cs
- TableLayoutColumnStyleCollection.cs
- WindowInteractionStateTracker.cs
- CommentEmitter.cs
- ComNativeDescriptor.cs
- GeneratedContractType.cs
- RuleSettingsCollection.cs
- ObjectQueryExecutionPlan.cs
- ContentOperations.cs
- FixedDocumentSequencePaginator.cs
- WindowsSecurityTokenAuthenticator.cs
- XmlAutoDetectWriter.cs
- DirectionalAction.cs
- ScriptServiceAttribute.cs
- Soap.cs
- OleCmdHelper.cs
- CacheVirtualItemsEvent.cs
- LiteralTextParser.cs
- HtmlTableCellCollection.cs
- RsaSecurityTokenAuthenticator.cs
- Errors.cs
- DataListCommandEventArgs.cs
- ExecutionPropertyManager.cs
- MissingMethodException.cs
- CapiHashAlgorithm.cs
- TargetConverter.cs
- DataSet.cs
- TextFindEngine.cs
- PageThemeCodeDomTreeGenerator.cs
- ClipboardProcessor.cs
- UserNameSecurityToken.cs
- ContainerActivationHelper.cs
- HtmlElementCollection.cs
- XmlSerializer.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- TimeSpanConverter.cs
- ArrangedElementCollection.cs
- DeflateInput.cs
- Inline.cs
- ActivityMarkupSerializationProvider.cs
- RewritingValidator.cs
- DPAPIProtectedConfigurationProvider.cs
- DocumentEventArgs.cs
- OutputCacheSection.cs
- DataBindingExpressionBuilder.cs
- CorrelationResolver.cs
- WaitHandle.cs
- WebPartAuthorizationEventArgs.cs
- DbTransaction.cs
- BindingCompleteEventArgs.cs
- FrameworkTemplate.cs
- AuthenticationModuleElementCollection.cs
- FactoryRecord.cs
- LineServices.cs
- ConfigurationPermission.cs
- XmlSchemaIdentityConstraint.cs
- Utils.cs
- MarkupProperty.cs
- NamedPipeTransportElement.cs
- ListViewGroupConverter.cs
- ContextMarshalException.cs
- OutputCacheSettings.cs
- ValueProviderWrapper.cs
- NativeMethodsOther.cs
- DataPagerFieldItem.cs
- SqlDelegatedTransaction.cs
- AssociationTypeEmitter.cs
- Pkcs9Attribute.cs
- ByteStack.cs
- RequiredFieldValidator.cs
- ItemsPanelTemplate.cs
- TreeNodeMouseHoverEvent.cs
- PartialCachingControl.cs
- Timer.cs
- TextHidden.cs
- FileAuthorizationModule.cs
- SystemResources.cs
- FontResourceCache.cs
- StringInfo.cs
- ExpressionSelection.cs
- SafeProcessHandle.cs
- MessageQueuePermissionEntry.cs
- NamespaceImport.cs
- webeventbuffer.cs
- InstanceDataCollection.cs
- EdmType.cs
- EmbeddedMailObject.cs
- AliasedSlot.cs
- HasCopySemanticsAttribute.cs
- FlatButtonAppearance.cs
- HMAC.cs
- ProcessHostMapPath.cs
- StringUtil.cs
- OlePropertyStructs.cs
- ProtocolImporter.cs
- RSAOAEPKeyExchangeFormatter.cs
- DllNotFoundException.cs