Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / Automation / Peers / GridViewItemAutomationPeer.cs / 1 / GridViewItemAutomationPeer.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;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Interop;
using System.Windows.Media;
using MS.Internal;
using MS.Win32;
namespace System.Windows.Automation.Peers
{
///
public class GridViewItemAutomationPeer : ListBoxItemAutomationPeer
{
///
public GridViewItemAutomationPeer(object owner, ListViewAutomationPeer listviewAP)
: base(owner, listviewAP)
{
Invariant.Assert(owner != null);
Invariant.Assert(listviewAP != null);
_item = owner;
_listviewAP = listviewAP;
}
///
override protected string GetClassNameCore()
{
return "ListViewItem";
}
///
override protected AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.DataItem;
}
///
protected override List GetChildrenCore()
{
ListView listview = _listviewAP.Owner as ListView;
Invariant.Assert(listview != null);
ListViewItem lvi = listview.ItemContainerGenerator.ContainerFromItem(_item) as ListViewItem;
if (lvi != null)
{
GridViewRowPresenter rowPresenter = GridViewAutomationPeer.FindVisualByType(lvi, typeof(GridViewRowPresenter)) as GridViewRowPresenter;
if (rowPresenter != null)
{
Hashtable oldChildren = _dataChildren; //cache the old ones for possible reuse
_dataChildren = new Hashtable(rowPresenter.ActualCells.Count);
List list = new List();
int row = listview.Items.IndexOf(_item);
int column = 0;
foreach (UIElement ele in rowPresenter.ActualCells)
{
GridViewCellAutomationPeer peer = (oldChildren == null ? null : (GridViewCellAutomationPeer)oldChildren[ele]);
if (peer == null)
{
if (ele is ContentPresenter)
{
peer = new GridViewCellAutomationPeer((ContentPresenter)ele, _listviewAP);
}
else if (ele is TextBlock)
{
peer = new GridViewCellAutomationPeer((TextBlock)ele, _listviewAP);
}
else
{
Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock");
}
}
//protection from indistinguishable UIElement - for example, 2 UIElement wiht same value
if (_dataChildren[ele] == null)
{
//Set Cell's row and column
peer.Column = column;
peer.Row = row;
list.Add(peer);
_dataChildren.Add(ele, peer);
column++;
}
}
return list;
}
}
return null;
}
#region Private Fields
private object _item;
private ListViewAutomationPeer _listviewAP;
private Hashtable _dataChildren = null;
#endregion
}
}
// 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
- ListBoxItem.cs
- DoubleAnimation.cs
- MissingFieldException.cs
- CleanUpVirtualizedItemEventArgs.cs
- DocumentViewerBase.cs
- ResourceContainer.cs
- DataBindEngine.cs
- ScaleTransform3D.cs
- ListViewContainer.cs
- PointCollectionConverter.cs
- Line.cs
- ImageCodecInfoPrivate.cs
- PasswordTextNavigator.cs
- mediaeventargs.cs
- EmbossBitmapEffect.cs
- ParentQuery.cs
- SqlDataSourceView.cs
- CookieHandler.cs
- NavigationPropertySingletonExpression.cs
- ListBindingConverter.cs
- HttpModuleActionCollection.cs
- HttpHostedTransportConfiguration.cs
- SqlStream.cs
- ScriptingJsonSerializationSection.cs
- Or.cs
- Highlights.cs
- AQNBuilder.cs
- RemotingAttributes.cs
- StandardOleMarshalObject.cs
- TraceHandlerErrorFormatter.cs
- VariantWrapper.cs
- XmlDownloadManager.cs
- Atom10FormatterFactory.cs
- TextStore.cs
- FunctionImportMapping.cs
- MenuItemCollection.cs
- ConnectionModeReader.cs
- COM2Properties.cs
- BasicBrowserDialog.designer.cs
- SessionStateItemCollection.cs
- FunctionQuery.cs
- DbConnectionPoolIdentity.cs
- ParamArrayAttribute.cs
- ConsumerConnectionPointCollection.cs
- StorageModelBuildProvider.cs
- HyperLink.cs
- unsafeIndexingFilterStream.cs
- MemberInfoSerializationHolder.cs
- Point3DCollection.cs
- SQLInt32Storage.cs
- UpDownBase.cs
- HttpCacheVary.cs
- TextTrailingCharacterEllipsis.cs
- EventMap.cs
- HyperLinkStyle.cs
- FilePresentation.cs
- FlowLayoutPanel.cs
- TreeView.cs
- Errors.cs
- ServiceOperationParameter.cs
- DataGridViewUtilities.cs
- __Filters.cs
- TextEffect.cs
- RuntimeConfigLKG.cs
- DataGridViewHitTestInfo.cs
- SurrogateDataContract.cs
- FocusManager.cs
- UnsafeNetInfoNativeMethods.cs
- DataGridViewColumnHeaderCell.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- COM2PropertyBuilderUITypeEditor.cs
- ToolStripPanel.cs
- ObjectDisposedException.cs
- DefaultPropertyAttribute.cs
- DbReferenceCollection.cs
- DetailsViewDeletedEventArgs.cs
- FrugalList.cs
- XmlSchemaGroup.cs
- coordinatorscratchpad.cs
- SpeechDetectedEventArgs.cs
- Figure.cs
- FlowDocumentPageViewerAutomationPeer.cs
- ParentUndoUnit.cs
- RequiredFieldValidator.cs
- CachedTypeface.cs
- XmlSchemaGroup.cs
- NullableDecimalAverageAggregationOperator.cs
- VirtualStackFrame.cs
- DescendentsWalkerBase.cs
- EndCreateSecurityTokenRequest.cs
- TraceContext.cs
- Matrix.cs
- oledbmetadatacolumnnames.cs
- HttpListenerPrefixCollection.cs
- CompilerScopeManager.cs
- SmtpNegotiateAuthenticationModule.cs
- LiteralTextContainerControlBuilder.cs
- SafeIUnknown.cs
- StringResourceManager.cs
- AutomationProperties.cs