Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / 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 http://avalon/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.
///
[Serializable()]
public class ReadOnlyObservableCollection : ReadOnlyCollection, INotifyCollectionChanged, INotifyPropertyChanged
{
#region Constructors
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
///
/// Initializes a new instance of ReadOnlyObservableCollection that
/// wraps the given ObservableCollection.
///
public ReadOnlyObservableCollection(ObservableCollection list) : 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
///
[field:NonSerializedAttribute()]
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
///
[field:NonSerializedAttribute()]
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.
//----------------------------------------------------------------------------
//
//
// Copyright (C) 2003 by Microsoft Corporation. All rights reserved.
//
//
//
// Description: Read-only wrapper around an ObservableCollection.
//
// See spec at http://avalon/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.
///
[Serializable()]
public class ReadOnlyObservableCollection : ReadOnlyCollection, INotifyCollectionChanged, INotifyPropertyChanged
{
#region Constructors
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
///
/// Initializes a new instance of ReadOnlyObservableCollection that
/// wraps the given ObservableCollection.
///
public ReadOnlyObservableCollection(ObservableCollection list) : 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
///
[field:NonSerializedAttribute()]
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
///
[field:NonSerializedAttribute()]
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
- Brush.cs
- GrammarBuilderBase.cs
- UshortList2.cs
- ValueConversionAttribute.cs
- PagerSettings.cs
- ServiceElementCollection.cs
- MemberBinding.cs
- DbConnectionPoolIdentity.cs
- ControlBuilder.cs
- GlobalItem.cs
- HtmlDocument.cs
- TargetPerspective.cs
- ResolveCriteria.cs
- UrlMappingsModule.cs
- Base64Stream.cs
- PolygonHotSpot.cs
- StreamWithDictionary.cs
- ReflectionUtil.cs
- _NegoState.cs
- Publisher.cs
- SymmetricSecurityBindingElement.cs
- ModelProperty.cs
- ButtonFieldBase.cs
- GridViewDeleteEventArgs.cs
- _FixedSizeReader.cs
- PerformanceCounterManager.cs
- CompilerTypeWithParams.cs
- PolicyManager.cs
- SystemGatewayIPAddressInformation.cs
- HitTestResult.cs
- SqlCommandBuilder.cs
- ServicePointManagerElement.cs
- C14NUtil.cs
- ParseHttpDate.cs
- COM2ExtendedUITypeEditor.cs
- Model3DCollection.cs
- ManagementPath.cs
- ContextProperty.cs
- ScriptingWebServicesSectionGroup.cs
- PropertyKey.cs
- BufferCache.cs
- HitTestWithPointDrawingContextWalker.cs
- WorkflowStateRollbackService.cs
- CreateBookmarkScope.cs
- PermissionRequestEvidence.cs
- MessageDescription.cs
- SiteMapPath.cs
- DataPagerFieldCommandEventArgs.cs
- ProxySimple.cs
- ResXResourceWriter.cs
- ComponentChangedEvent.cs
- DeploymentSection.cs
- DiscoveryReferences.cs
- _ListenerResponseStream.cs
- EmbeddedMailObjectsCollection.cs
- SerializerDescriptor.cs
- PropertyPathConverter.cs
- SingleKeyFrameCollection.cs
- TempFiles.cs
- Symbol.cs
- SystemInfo.cs
- SafeCertificateStore.cs
- LoginName.cs
- TabItemAutomationPeer.cs
- SelectionEditingBehavior.cs
- RegexTree.cs
- RuntimeConfigurationRecord.cs
- ZipIOExtraField.cs
- TextSimpleMarkerProperties.cs
- TripleDESCryptoServiceProvider.cs
- Stream.cs
- AssociativeAggregationOperator.cs
- TdsParserStaticMethods.cs
- BuildProvider.cs
- X509SecurityToken.cs
- StyleConverter.cs
- DocumentOrderComparer.cs
- PreservationFileWriter.cs
- RegexParser.cs
- IntSecurity.cs
- KoreanLunisolarCalendar.cs
- ColorConvertedBitmap.cs
- ElementProxy.cs
- RotateTransform.cs
- SqlReferenceCollection.cs
- WebPartDisplayMode.cs
- DataGridViewTextBoxEditingControl.cs
- OdbcConnectionHandle.cs
- indexingfiltermarshaler.cs
- CustomGrammar.cs
- IdentifierCollection.cs
- XmlDataSourceView.cs
- HtmlHead.cs
- BoolLiteral.cs
- TextRunCache.cs
- DeflateStreamAsyncResult.cs
- CompatibleIComparer.cs
- NotSupportedException.cs
- DebuggerAttributes.cs
- XmlSubtreeReader.cs