Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / Automation / Peers / GroupItemAutomationPeer.cs / 1 / GroupItemAutomationPeer.cs
using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security; using System.Text; using System.Windows; using System.Windows.Automation.Provider; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Interop; using System.Windows.Media; using MS.Internal; using MS.Win32; namespace System.Windows.Automation.Peers { /// public class GroupItemAutomationPeer : FrameworkElementAutomationPeer { /// public GroupItemAutomationPeer(GroupItem owner): base(owner) { } /// override protected string GetClassNameCore() { return "GroupItem"; } /// override protected AutomationControlType GetAutomationControlTypeCore() { return AutomationControlType.Group; } /// protected override ListGetChildrenCore() { GroupItem owner = (GroupItem)Owner; ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(Owner); ItemsControlAutomationPeer itemsControlAP = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer; ItemContainerGenerator generator = owner.Generator; if (generator != null) { IList items = generator.Items; List children = new List (items.Count); ItemPeersStorage oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new ItemPeersStorage(); if (items.Count > 0) { foreach (object item in items) { CollectionViewGroup cvg = item as CollectionViewGroup; if (cvg != null) { GroupItem groupItem = generator.ContainerFromItem(item) as GroupItem; if (groupItem != null) { GroupItemAutomationPeer peer = groupItem.CreateAutomationPeer() as GroupItemAutomationPeer; if (peer != null) children.Add(peer); } } else { //try to reuse old peer if it exists ItemAutomationPeer peer = oldChildren[item]; //no old peer - create new one if (peer == null) peer = itemsControlAP.CreateItemAutomationPeerInternal(item); //perform hookup so the events sourced from wrapper peer are fired as if from the data item if (peer != null) { AutomationPeer wrapperPeer = peer.GetWrapperPeer(); if (wrapperPeer != null) wrapperPeer.EventsSource = peer; } //protection from indistinguishable items - for example, 2 strings with same value //this scenario does not work in ItemsControl however is not checked for. if (_dataChildren[item] == null) { children.Add(peer); _dataChildren[item] = peer; // Update ItemsControl cache too // ItemPeers needs to be updated because used in Selector and other ItemsControl subclasses to access item peers directly if (itemsControlAP.ItemPeers[item] == null) { itemsControlAP.ItemPeers[item] = peer; } } } } return children; } } return null; } private ItemPeersStorage _dataChildren = new ItemPeersStorage(); } } // 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
- wmiprovider.cs
- ClaimComparer.cs
- UnauthorizedAccessException.cs
- PerformanceCounter.cs
- KeyTime.cs
- ClientBuildManager.cs
- ListControl.cs
- RadioButtonList.cs
- BulletChrome.cs
- BoundingRectTracker.cs
- Util.cs
- XXXOnTypeBuilderInstantiation.cs
- IteratorDescriptor.cs
- HttpGetClientProtocol.cs
- HtmlButton.cs
- StorageComplexTypeMapping.cs
- SessionParameter.cs
- HtmlTableRowCollection.cs
- WebPartChrome.cs
- BezierSegment.cs
- Exceptions.cs
- Converter.cs
- recordstatefactory.cs
- CultureInfoConverter.cs
- CommandHelpers.cs
- InvokeWebService.cs
- TextContainerChangedEventArgs.cs
- LinkArea.cs
- DatatypeImplementation.cs
- SessionStateSection.cs
- DoubleLink.cs
- XmlNamespaceManager.cs
- diagnosticsswitches.cs
- FileDialogCustomPlacesCollection.cs
- BufferModesCollection.cs
- CharacterShapingProperties.cs
- ITreeGenerator.cs
- MimeMultiPart.cs
- XamlSerializerUtil.cs
- Expressions.cs
- AuthorizationContext.cs
- DateTimeOffsetAdapter.cs
- DESCryptoServiceProvider.cs
- RichTextBox.cs
- Size.cs
- WSFederationHttpBindingCollectionElement.cs
- StrokeCollectionConverter.cs
- ResourceReferenceExpression.cs
- BoolExpression.cs
- GetChildSubtree.cs
- ObservableDictionary.cs
- ToolStripRenderEventArgs.cs
- ObjectItemCollection.cs
- TreeNodeBinding.cs
- Deflater.cs
- FragmentQueryKB.cs
- AdornerHitTestResult.cs
- PasswordBoxAutomationPeer.cs
- EntityDataSourceChangedEventArgs.cs
- PolicyStatement.cs
- MbpInfo.cs
- JsonEncodingStreamWrapper.cs
- CommandManager.cs
- CategoryNameCollection.cs
- ConnectionPoolManager.cs
- GACIdentityPermission.cs
- SectionInformation.cs
- EnumerableRowCollectionExtensions.cs
- ParallelTimeline.cs
- OutOfProcStateClientManager.cs
- WorkerRequest.cs
- SqlTriggerAttribute.cs
- ProbeDuplex11AsyncResult.cs
- ServiceObjectContainer.cs
- SmiTypedGetterSetter.cs
- CellPartitioner.cs
- Metadata.cs
- SynchronizedCollection.cs
- ResourceKey.cs
- XmlDigitalSignatureProcessor.cs
- MetabaseServerConfig.cs
- DataServiceException.cs
- GraphicsPath.cs
- DropTarget.cs
- CodeExpressionCollection.cs
- RenderOptions.cs
- TileModeValidation.cs
- HttpCacheParams.cs
- StreamResourceInfo.cs
- ClientFormsIdentity.cs
- ObjectComplexPropertyMapping.cs
- RegexBoyerMoore.cs
- PrefixHandle.cs
- TypeSystem.cs
- CompiledQueryCacheKey.cs
- DictionaryManager.cs
- FontEmbeddingManager.cs
- HeaderElement.cs
- EndpointInfo.cs
- ResponseStream.cs