Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / 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); if (itemsControl != null) { ItemsControlAutomationPeer itemsControlAP = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer; if (itemsControlAP != null) { 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. 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 List GetChildrenCore() { GroupItem owner = (GroupItem)Owner; ItemsControl itemsControl = ItemsControl.ItemsControlFromItemContainer(Owner); if (itemsControl != null) { ItemsControlAutomationPeer itemsControlAP = itemsControl.CreateAutomationPeer() as ItemsControlAutomationPeer; if (itemsControlAP != null) { 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
- AutomationPeer.cs
- ConfigurationSettings.cs
- RenderCapability.cs
- StackSpiller.cs
- HttpRequest.cs
- ToolStripItem.cs
- SecureConversationDriver.cs
- CollectionDataContractAttribute.cs
- InfoCardSchemas.cs
- InputBindingCollection.cs
- ParamArrayAttribute.cs
- IHttpResponseInternal.cs
- ReliableSessionBindingElement.cs
- SHA512Managed.cs
- TagMapCollection.cs
- SmiConnection.cs
- Action.cs
- XmlSerializerVersionAttribute.cs
- HwndProxyElementProvider.cs
- LabelInfo.cs
- ELinqQueryState.cs
- RawTextInputReport.cs
- IgnoreFlushAndCloseStream.cs
- Socket.cs
- StoreAnnotationsMap.cs
- DesignerRegionCollection.cs
- DrawingGroup.cs
- ObjectQuery_EntitySqlExtensions.cs
- NonValidatingSecurityTokenAuthenticator.cs
- GridViewCommandEventArgs.cs
- GPRECT.cs
- IResourceProvider.cs
- ImageButton.cs
- SHA1.cs
- SafeHandle.cs
- UrlAuthFailedErrorFormatter.cs
- ProvideValueServiceProvider.cs
- WindowsPen.cs
- Subtree.cs
- FormatException.cs
- OutOfMemoryException.cs
- FormatConvertedBitmap.cs
- BindingList.cs
- EntityDataSourceDesigner.cs
- EmbeddedObject.cs
- NetworkStream.cs
- StylusOverProperty.cs
- AssemblyCache.cs
- InvalidFilterCriteriaException.cs
- CallbackHandler.cs
- TagMapCollection.cs
- EdmError.cs
- StringStorage.cs
- UnsafeNativeMethodsTablet.cs
- EnumConverter.cs
- NonParentingControl.cs
- ChameleonKey.cs
- PrintController.cs
- HtmlElement.cs
- SafeTokenHandle.cs
- OdbcConnectionString.cs
- CompilationSection.cs
- DeferredBinaryDeserializerExtension.cs
- XamlTemplateSerializer.cs
- ClientType.cs
- TemplateLookupAction.cs
- XmlWrappingReader.cs
- CodeCompileUnit.cs
- TypeBuilder.cs
- DoubleLinkList.cs
- ObjectNavigationPropertyMapping.cs
- UInt16.cs
- OleDbParameterCollection.cs
- RsaSecurityKey.cs
- SignedPkcs7.cs
- DataControlPagerLinkButton.cs
- UncommonField.cs
- SafeNativeMethods.cs
- MarkupExtensionSerializer.cs
- StringWriter.cs
- DbResourceAllocator.cs
- DeploymentSectionCache.cs
- ContextMenu.cs
- SerializationInfoEnumerator.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- MimeBasePart.cs
- ClientScriptItem.cs
- remotingproxy.cs
- ModuleBuilder.cs
- rsa.cs
- XmlSchemaObjectCollection.cs
- ChildrenQuery.cs
- DefaultMemberAttribute.cs
- Converter.cs
- PropertyChangeTracker.cs
- XmlDesignerDataSourceView.cs
- AtomContentProperty.cs
- ApplicationInfo.cs
- WorkflowDebuggerSteppingAttribute.cs
- PriorityRange.cs