Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DescendentsWalkerBase.cs / 1305600 / 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; } /// /// 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
- EditingMode.cs
- ServiceDeploymentInfo.cs
- WindowsAltTab.cs
- DataControlFieldHeaderCell.cs
- LocalizableAttribute.cs
- FileAuthorizationModule.cs
- DiffuseMaterial.cs
- HtmlProps.cs
- metadatamappinghashervisitor.cs
- PopOutPanel.cs
- StyleTypedPropertyAttribute.cs
- HtmlToClrEventProxy.cs
- FloatUtil.cs
- graph.cs
- ContractMethodParameterInfo.cs
- Codec.cs
- OdbcConnection.cs
- NetTcpBinding.cs
- DependencyPropertyKey.cs
- ReflectPropertyDescriptor.cs
- ChangePasswordDesigner.cs
- InputReferenceExpression.cs
- Calendar.cs
- DesignerWebPartChrome.cs
- TreeNodeStyleCollection.cs
- UpWmlMobileTextWriter.cs
- SystemIcmpV4Statistics.cs
- NetMsmqBindingElement.cs
- ItemsControlAutomationPeer.cs
- Pen.cs
- Vertex.cs
- DataTemplate.cs
- GridLengthConverter.cs
- FontWeightConverter.cs
- StringUtil.cs
- HtmlControl.cs
- ReadWriteObjectLock.cs
- MaskedTextBoxTextEditor.cs
- ClientSettingsProvider.cs
- RestHandlerFactory.cs
- ClientTarget.cs
- CheckBox.cs
- OdbcRowUpdatingEvent.cs
- Binding.cs
- BindingExpressionBase.cs
- CallId.cs
- SpeakInfo.cs
- ShapeTypeface.cs
- VirtualPath.cs
- StagingAreaInputItem.cs
- VirtualizedCellInfoCollection.cs
- PropertyIDSet.cs
- WebPartConnectVerb.cs
- PathFigureCollection.cs
- Crypto.cs
- SortFieldComparer.cs
- Int32KeyFrameCollection.cs
- DigitShape.cs
- TreeNodeBinding.cs
- AutoCompleteStringCollection.cs
- XmlHierarchicalDataSourceView.cs
- VirtualPathUtility.cs
- BooleanConverter.cs
- ExecutionEngineException.cs
- Soap12ServerProtocol.cs
- Border.cs
- DesignerOptions.cs
- dtdvalidator.cs
- WebErrorHandler.cs
- Unit.cs
- MustUnderstandSoapException.cs
- MatrixTransform.cs
- ErrorHandler.cs
- CommandEventArgs.cs
- ComponentChangingEvent.cs
- DataGridViewCellCollection.cs
- RoleManagerSection.cs
- Polyline.cs
- SessionStateUtil.cs
- IdentityModelDictionary.cs
- GeneralTransformGroup.cs
- ContractMapping.cs
- PeerCredentialElement.cs
- TransactionProxy.cs
- Activator.cs
- KerberosRequestorSecurityToken.cs
- CryptoConfig.cs
- SwitchAttribute.cs
- CursorConverter.cs
- SqlDataAdapter.cs
- BookmarkResumptionRecord.cs
- ToolStripDropDownItem.cs
- MailAddressCollection.cs
- SizeAnimationBase.cs
- DataGridPagerStyle.cs
- XDeferredAxisSource.cs
- XomlCompilerResults.cs
- DbModificationClause.cs
- DataObjectMethodAttribute.cs
- XPathException.cs