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
- SqlCachedBuffer.cs
- ComboBoxDesigner.cs
- HyperLinkField.cs
- FileDetails.cs
- Vector3DIndependentAnimationStorage.cs
- ListenerSessionConnection.cs
- ToolStripOverflowButton.cs
- PromptEventArgs.cs
- DispatcherExceptionFilterEventArgs.cs
- QilReference.cs
- FontWeights.cs
- UInt16Converter.cs
- SqlCacheDependencyDatabaseCollection.cs
- VarRefManager.cs
- CodeGroup.cs
- MethodExpr.cs
- NamespaceInfo.cs
- XmlSchemaAnyAttribute.cs
- InfiniteIntConverter.cs
- X509Utils.cs
- RealizationDrawingContextWalker.cs
- FileDocument.cs
- MobileUserControlDesigner.cs
- FilterQuery.cs
- XamlDesignerSerializationManager.cs
- HelpProvider.cs
- WmpBitmapEncoder.cs
- IconConverter.cs
- BaseResourcesBuildProvider.cs
- ObjectManager.cs
- wgx_sdk_version.cs
- UnmanagedHandle.cs
- columnmapkeybuilder.cs
- RuntimeConfig.cs
- Int32CollectionValueSerializer.cs
- DES.cs
- FloaterBaseParagraph.cs
- HashAlgorithm.cs
- KerberosRequestorSecurityTokenAuthenticator.cs
- Light.cs
- AggregateNode.cs
- ListViewAutomationPeer.cs
- OrderedEnumerableRowCollection.cs
- SemanticTag.cs
- PreProcessInputEventArgs.cs
- SupportsEventValidationAttribute.cs
- MiniMapControl.xaml.cs
- httpstaticobjectscollection.cs
- PropertyChangingEventArgs.cs
- TextDecorationLocationValidation.cs
- ActivityInstanceReference.cs
- SwitchLevelAttribute.cs
- HttpModuleCollection.cs
- UnicastIPAddressInformationCollection.cs
- _UriTypeConverter.cs
- CustomAssemblyResolver.cs
- TypeContext.cs
- Parameter.cs
- PermissionRequestEvidence.cs
- AppDomainProtocolHandler.cs
- ResourceKey.cs
- HandoffBehavior.cs
- UidPropertyAttribute.cs
- BooleanSwitch.cs
- ApplicationActivator.cs
- DoubleUtil.cs
- TypeDescriptionProviderAttribute.cs
- JsonDataContract.cs
- Thread.cs
- EntityViewGenerationAttribute.cs
- MethodBody.cs
- XpsS0ValidatingLoader.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- SourceFileInfo.cs
- CompatibleComparer.cs
- HtmlControl.cs
- PassportAuthenticationEventArgs.cs
- ColorContext.cs
- URLBuilder.cs
- FixedSchema.cs
- GenericFlowSwitchHelper.cs
- DefaultSection.cs
- ReceiveCompletedEventArgs.cs
- AutomationPattern.cs
- TraceHwndHost.cs
- XmlUnspecifiedAttribute.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- PathNode.cs
- WebPartEditorApplyVerb.cs
- ProxySimple.cs
- NonClientArea.cs
- SoapEnumAttribute.cs
- DataBindingHandlerAttribute.cs
- WmlValidationSummaryAdapter.cs
- PanelDesigner.cs
- TransformedBitmap.cs
- TraceAsyncResult.cs
- SourceSwitch.cs
- CodeDelegateCreateExpression.cs
- ExtenderProvidedPropertyAttribute.cs