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
- UnsafeNativeMethodsTablet.cs
- TableLayoutPanelCodeDomSerializer.cs
- SpellerHighlightLayer.cs
- MachineKeyConverter.cs
- CssTextWriter.cs
- ConfigUtil.cs
- Int32CAMarshaler.cs
- ChannelTokenTypeConverter.cs
- DataGridViewCell.cs
- UnhandledExceptionEventArgs.cs
- RSAProtectedConfigurationProvider.cs
- HuffModule.cs
- SmtpAuthenticationManager.cs
- Fx.cs
- CodeDomSerializationProvider.cs
- LocalizationComments.cs
- DispatcherSynchronizationContext.cs
- TreeViewHitTestInfo.cs
- ExceptionHelpers.cs
- DependentList.cs
- ListViewItemMouseHoverEvent.cs
- CodeGenHelper.cs
- XmlIlVisitor.cs
- SpellerInterop.cs
- MulticastNotSupportedException.cs
- DateTimeOffset.cs
- Utility.cs
- DecimalConverter.cs
- SetterBase.cs
- SqlDataSourceConfigureFilterForm.cs
- TrailingSpaceComparer.cs
- MessageBox.cs
- QilXmlWriter.cs
- BooleanKeyFrameCollection.cs
- Processor.cs
- ClosableStream.cs
- GridItemProviderWrapper.cs
- DataGridViewRowStateChangedEventArgs.cs
- TraceEventCache.cs
- ActivityExecutorSurrogate.cs
- HttpChannelBindingToken.cs
- TextRangeEditLists.cs
- NameValuePermission.cs
- DateTimeOffsetConverter.cs
- AppDomainInfo.cs
- LazyTextWriterCreator.cs
- DotNetATv1WindowsLogEntrySerializer.cs
- TableLayoutCellPaintEventArgs.cs
- ScriptResourceAttribute.cs
- TemplateEditingService.cs
- errorpatternmatcher.cs
- GenericWebPart.cs
- CompressionTransform.cs
- StringHandle.cs
- DynamicValidatorEventArgs.cs
- SignatureDescription.cs
- DuplicateWaitObjectException.cs
- HttpPostedFile.cs
- ExecutionProperties.cs
- ContractTypeNameCollection.cs
- FactoryId.cs
- SctClaimDictionary.cs
- ExpandCollapseProviderWrapper.cs
- MethodBody.cs
- DataSourceCacheDurationConverter.cs
- AppSettingsSection.cs
- SqlWorkflowInstanceStoreLock.cs
- IQueryable.cs
- ContainerActivationHelper.cs
- ThreadStartException.cs
- InheritanceContextChangedEventManager.cs
- XmlNodeComparer.cs
- SvcFileManager.cs
- ExpressionBuilderCollection.cs
- SetterTriggerConditionValueConverter.cs
- TextBoxRenderer.cs
- LifetimeMonitor.cs
- CachedBitmap.cs
- Visual3D.cs
- Int32AnimationUsingKeyFrames.cs
- WindowsTab.cs
- ValidatorUtils.cs
- PageWrapper.cs
- EventDescriptorCollection.cs
- ObjectQueryState.cs
- PerformanceCountersElement.cs
- PagerSettings.cs
- Rect3D.cs
- InternalDuplexChannelListener.cs
- InputBinding.cs
- LineSegment.cs
- AdRotator.cs
- SerializationTrace.cs
- BitConverter.cs
- ColorAnimation.cs
- AccessibleObject.cs
- ActivationArguments.cs
- Menu.cs
- PersonalizationProviderCollection.cs
- InputLanguageCollection.cs