Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Base / System / Collections / ObjectModel / ReadOnlyObservableCollection.cs / 1 / ReadOnlyObservableCollection.cs
//---------------------------------------------------------------------------- // //// Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // // Description: Read-only wrapper around an ObservableCollection. // // See spec at [....]/connecteddata/Specs/Collection%20Interfaces.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; namespace System.Collections.ObjectModel { ////// Read-only wrapper around an ObservableCollection. /// public class ReadOnlyObservableCollection: ReadOnlyCollection , INotifyCollectionChanged, INotifyPropertyChanged { #region Constructors //----------------------------------------------------- // // Constructors // //----------------------------------------------------- /// /// Initializes a new instance of ReadOnlyObservableCollection that /// wraps the given ObservableCollection. /// public ReadOnlyObservableCollection(ObservableCollectionlist) : base(list) { ((INotifyCollectionChanged)Items).CollectionChanged += new NotifyCollectionChangedEventHandler(HandleCollectionChanged); ((INotifyPropertyChanged)Items).PropertyChanged += new PropertyChangedEventHandler(HandlePropertyChanged); } #endregion Constructors #region Interfaces //------------------------------------------------------ // // Interfaces // //----------------------------------------------------- #region INotifyCollectionChanged /// /// CollectionChanged event (per event NotifyCollectionChangedEventHandler INotifyCollectionChanged.CollectionChanged { add { CollectionChanged += value; } remove { CollectionChanged -= value; } } ///). /// /// Occurs when the collection changes, either by adding or removing an item. /// ////// see protected virtual event NotifyCollectionChangedEventHandler CollectionChanged; ////// /// raise CollectionChanged event to any listeners /// protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args) { if (CollectionChanged != null) { CollectionChanged(this, args); } } #endregion INotifyCollectionChanged #region INotifyPropertyChanged ////// PropertyChanged event (per event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { PropertyChanged += value; } remove { PropertyChanged -= value; } } ///). /// /// Occurs when a property changes. /// ////// see protected virtual event PropertyChangedEventHandler PropertyChanged; ////// /// raise PropertyChanged event to any listeners /// protected virtual void OnPropertyChanged(PropertyChangedEventArgs args) { if (PropertyChanged != null) { PropertyChanged(this, args); } } #endregion INotifyPropertyChanged #endregion Interfaces #region Private Methods //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ // forward CollectionChanged events from the base list to our listeners void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { OnCollectionChanged(e); } // forward PropertyChanged events from the base list to our listeners void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e); } #endregion Private Methods #region Private Fields //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #endregion Private Fields } } // 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
- ProcessMonitor.cs
- MachinePropertyVariants.cs
- XamlVector3DCollectionSerializer.cs
- SerializationInfoEnumerator.cs
- CodeSnippetExpression.cs
- _NestedSingleAsyncResult.cs
- InstanceDataCollectionCollection.cs
- TabItemAutomationPeer.cs
- DefaultProxySection.cs
- SingleObjectCollection.cs
- ExpressionCopier.cs
- CheckPair.cs
- WindowsFont.cs
- RestClientProxyHandler.cs
- DrawingAttributesDefaultValueFactory.cs
- SqlCacheDependencyDatabaseCollection.cs
- ConnectionConsumerAttribute.cs
- ConversionContext.cs
- IxmlLineInfo.cs
- InputReferenceExpression.cs
- SchemaInfo.cs
- CacheDependency.cs
- SecurityUniqueId.cs
- TextServicesDisplayAttributePropertyRanges.cs
- ParseChildrenAsPropertiesAttribute.cs
- Adorner.cs
- AdapterDictionary.cs
- ObjectFullSpanRewriter.cs
- SafeSecurityHelper.cs
- InternalTypeHelper.cs
- Exceptions.cs
- DynamicResourceExtension.cs
- EtwTrace.cs
- Pens.cs
- PolyBezierSegment.cs
- SAPIEngineTypes.cs
- BufferedGraphicsContext.cs
- MailBnfHelper.cs
- CodeMethodReturnStatement.cs
- DateTimeOffsetConverter.cs
- FontDifferentiator.cs
- ButtonPopupAdapter.cs
- Set.cs
- QuestionEventArgs.cs
- EmptyEnumerator.cs
- CodeGotoStatement.cs
- ComUdtElement.cs
- AppDomainFactory.cs
- PrtTicket_Base.cs
- Main.cs
- XPathBinder.cs
- ChangeConflicts.cs
- WorkflowViewManager.cs
- SafeWaitHandle.cs
- ArithmeticLiteral.cs
- PerformanceCountersBase.cs
- ConfigXmlElement.cs
- MimeTypeAttribute.cs
- GridLengthConverter.cs
- WindowsNonControl.cs
- SoapSchemaImporter.cs
- CheckBoxAutomationPeer.cs
- Decimal.cs
- TextStore.cs
- ArraySubsetEnumerator.cs
- StaticDataManager.cs
- recordstate.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- LabelEditEvent.cs
- CacheEntry.cs
- KeyInterop.cs
- CAGDesigner.cs
- XamlReaderConstants.cs
- XDeferredAxisSource.cs
- Double.cs
- OleDbFactory.cs
- ObjectListGeneralPage.cs
- GlyphCollection.cs
- counter.cs
- TextServicesCompartmentContext.cs
- PointCollectionValueSerializer.cs
- LoginUtil.cs
- HttpRequestMessageProperty.cs
- X509CertificateValidator.cs
- SystemResourceHost.cs
- TraceContext.cs
- Tile.cs
- ToolStripPanelRenderEventArgs.cs
- JavascriptCallbackBehaviorAttribute.cs
- TypeSystem.cs
- BamlRecordReader.cs
- HttpConfigurationContext.cs
- TextFormatterHost.cs
- FormViewInsertEventArgs.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- Pkcs9Attribute.cs
- Coordinator.cs
- TextDecorationCollection.cs
- OSEnvironmentHelper.cs
- Int16Animation.cs