Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / Primitives / DataGridRowsPresenter.cs / 1305600 / DataGridRowsPresenter.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Threading; using MS.Internal; namespace System.Windows.Controls.Primitives { ////// Panel that lays out individual rows top to bottom. /// public class DataGridRowsPresenter : VirtualizingStackPanel { #region Scroll Methods ////// Calls the protected method BringIndexIntoView. /// /// The index of the row to scroll into view. ////// BringIndexIntoView should be callable either from the ItemsControl /// or directly on the panel. This was not done in WPF, so we are /// building this internally for the DataGrid. However, if a public /// way of calling BringIndexIntoView becomes a reality, then /// this method is no longer needed. /// internal void InternalBringIndexIntoView(int index) { BringIndexIntoView(index); } ////// This method is invoked when the IsItemsHost property changes. /// /// The old value of the IsItemsHost property. /// The new value of the IsItemsHost property. protected override void OnIsItemsHostChanged(bool oldIsItemsHost, bool newIsItemsHost) { base.OnIsItemsHostChanged(oldIsItemsHost, newIsItemsHost); if (newIsItemsHost) { DataGrid dataGrid = Owner; if (dataGrid != null) { // ItemsHost should be the "root" element which has // IsItemsHost = true on it. In the case of grouping, // IsItemsHost is true on all panels which are generating // content. Thus, we care only about the panel which // is generating content for the ItemsControl. IItemContainerGenerator generator = dataGrid.ItemContainerGenerator as IItemContainerGenerator; if (generator != null && generator == generator.GetItemContainerGeneratorForPanel(this)) { dataGrid.InternalItemsHost = this; } } } else { // No longer the items host, clear out the property on the DataGrid if ((_owner != null) && (_owner.InternalItemsHost == this)) { _owner.InternalItemsHost = null; } _owner = null; } } ////// Override of ViewportSizeChanged method which enqueues a dispatcher operation to redistribute /// the width among columns. /// /// viewport size before the change /// viewport size after the change protected override void OnViewportSizeChanged(Size oldViewportSize, Size newViewportSize) { DataGrid dataGrid = Owner; if (dataGrid != null) { ScrollContentPresenter scrollContentPresenter = dataGrid.InternalScrollContentPresenter; if (scrollContentPresenter == null || scrollContentPresenter.CanContentScroll) { dataGrid.OnViewportSizeChanged(oldViewportSize, newViewportSize); } } } #endregion #region Column Virtualization ////// Measure /// protected override Size MeasureOverride(Size constraint) { _availableSize = constraint; return base.MeasureOverride(constraint); } ////// Property which returns the last measure input size /// internal Size AvailableSize { get { return _availableSize; } } #endregion #region Row Virtualization ////// Override method to suppress the cleanup of rows /// with validation errors. /// /// protected override void OnCleanUpVirtualizedItem(CleanUpVirtualizedItemEventArgs e) { base.OnCleanUpVirtualizedItem(e); if (e.UIElement != null && Validation.GetHasError(e.UIElement)) { e.Cancel = true; } } #endregion #region Helpers internal DataGrid Owner { get { if (_owner == null) { _owner = ItemsControl.GetItemsOwner(this) as DataGrid; } return _owner; } } #endregion #region Data private DataGrid _owner; private Size _availableSize; #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Threading; using MS.Internal; namespace System.Windows.Controls.Primitives { ////// Panel that lays out individual rows top to bottom. /// public class DataGridRowsPresenter : VirtualizingStackPanel { #region Scroll Methods ////// Calls the protected method BringIndexIntoView. /// /// The index of the row to scroll into view. ////// BringIndexIntoView should be callable either from the ItemsControl /// or directly on the panel. This was not done in WPF, so we are /// building this internally for the DataGrid. However, if a public /// way of calling BringIndexIntoView becomes a reality, then /// this method is no longer needed. /// internal void InternalBringIndexIntoView(int index) { BringIndexIntoView(index); } ////// This method is invoked when the IsItemsHost property changes. /// /// The old value of the IsItemsHost property. /// The new value of the IsItemsHost property. protected override void OnIsItemsHostChanged(bool oldIsItemsHost, bool newIsItemsHost) { base.OnIsItemsHostChanged(oldIsItemsHost, newIsItemsHost); if (newIsItemsHost) { DataGrid dataGrid = Owner; if (dataGrid != null) { // ItemsHost should be the "root" element which has // IsItemsHost = true on it. In the case of grouping, // IsItemsHost is true on all panels which are generating // content. Thus, we care only about the panel which // is generating content for the ItemsControl. IItemContainerGenerator generator = dataGrid.ItemContainerGenerator as IItemContainerGenerator; if (generator != null && generator == generator.GetItemContainerGeneratorForPanel(this)) { dataGrid.InternalItemsHost = this; } } } else { // No longer the items host, clear out the property on the DataGrid if ((_owner != null) && (_owner.InternalItemsHost == this)) { _owner.InternalItemsHost = null; } _owner = null; } } ////// Override of ViewportSizeChanged method which enqueues a dispatcher operation to redistribute /// the width among columns. /// /// viewport size before the change /// viewport size after the change protected override void OnViewportSizeChanged(Size oldViewportSize, Size newViewportSize) { DataGrid dataGrid = Owner; if (dataGrid != null) { ScrollContentPresenter scrollContentPresenter = dataGrid.InternalScrollContentPresenter; if (scrollContentPresenter == null || scrollContentPresenter.CanContentScroll) { dataGrid.OnViewportSizeChanged(oldViewportSize, newViewportSize); } } } #endregion #region Column Virtualization ////// Measure /// protected override Size MeasureOverride(Size constraint) { _availableSize = constraint; return base.MeasureOverride(constraint); } ////// Property which returns the last measure input size /// internal Size AvailableSize { get { return _availableSize; } } #endregion #region Row Virtualization ////// Override method to suppress the cleanup of rows /// with validation errors. /// /// protected override void OnCleanUpVirtualizedItem(CleanUpVirtualizedItemEventArgs e) { base.OnCleanUpVirtualizedItem(e); if (e.UIElement != null && Validation.GetHasError(e.UIElement)) { e.Cancel = true; } } #endregion #region Helpers internal DataGrid Owner { get { if (_owner == null) { _owner = ItemsControl.GetItemsOwner(this) as DataGrid; } return _owner; } } #endregion #region Data private DataGrid _owner; private Size _availableSize; #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
- XmlObjectSerializer.cs
- SecurityRuntime.cs
- ApplicationSecurityInfo.cs
- FunctionDescription.cs
- DSASignatureDeformatter.cs
- GradientSpreadMethodValidation.cs
- ApplicationGesture.cs
- AnchoredBlock.cs
- PKCS1MaskGenerationMethod.cs
- SoapFault.cs
- OleTxTransaction.cs
- OutOfProcStateClientManager.cs
- DetailsViewDeletedEventArgs.cs
- ZoomingMessageFilter.cs
- ConstraintCollection.cs
- DataGridViewMethods.cs
- SmiXetterAccessMap.cs
- DrawingGroup.cs
- WebBrowser.cs
- BitSet.cs
- ToolStripGripRenderEventArgs.cs
- XmlBinaryWriterSession.cs
- QueryPrefixOp.cs
- FlowDocument.cs
- NameValueFileSectionHandler.cs
- Int32AnimationUsingKeyFrames.cs
- CompModSwitches.cs
- InvalidOleVariantTypeException.cs
- XmlAnyElementAttribute.cs
- DispatchWrapper.cs
- DoubleAnimationUsingPath.cs
- OleDbConnection.cs
- WebServiceTypeData.cs
- XPathException.cs
- BinaryUtilClasses.cs
- PrefixQName.cs
- LabelLiteral.cs
- XmlSerializationGeneratedCode.cs
- IntegerValidator.cs
- WindowsListView.cs
- ControlDesigner.cs
- TdsParser.cs
- _ConnectStream.cs
- DataGridViewUtilities.cs
- OdbcConnection.cs
- MonthCalendarDesigner.cs
- ToolZone.cs
- RootCodeDomSerializer.cs
- RestClientProxyHandler.cs
- FlagsAttribute.cs
- ExpressionBuilderContext.cs
- WebPartCatalogCloseVerb.cs
- ColumnWidthChangingEvent.cs
- LocalValueEnumerator.cs
- MonthCalendarDesigner.cs
- ResourcePool.cs
- SspiSafeHandles.cs
- DefaultMemberAttribute.cs
- ItemsControl.cs
- ControllableStoryboardAction.cs
- SystemMulticastIPAddressInformation.cs
- AlternateView.cs
- AppDomainManager.cs
- Gdiplus.cs
- OracleBoolean.cs
- XmlWrappingReader.cs
- DWriteFactory.cs
- XmlExceptionHelper.cs
- WindowsHyperlink.cs
- InputLangChangeRequestEvent.cs
- XmlSchemaSequence.cs
- TreeViewItem.cs
- CompilerState.cs
- TypefaceMap.cs
- AddInBase.cs
- GridItem.cs
- Form.cs
- X509Utils.cs
- ViewDesigner.cs
- MinMaxParagraphWidth.cs
- ProgressBar.cs
- ScaleTransform.cs
- MaskDesignerDialog.cs
- SpeechEvent.cs
- CollectionType.cs
- Visual3D.cs
- FontStyleConverter.cs
- QuadraticEase.cs
- ObsoleteAttribute.cs
- DirectoryObjectSecurity.cs
- mactripleDES.cs
- DefaultHttpHandler.cs
- FigureHelper.cs
- IdentitySection.cs
- sqlnorm.cs
- WebPartTransformer.cs
- BinaryEditor.cs
- PolyBezierSegmentFigureLogic.cs
- BufferedStream.cs
- ThemeDirectoryCompiler.cs