Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Data / PriorityBinding.cs / 1305600 / PriorityBinding.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Defines PriorityBinding object, which stores information // for creating instances of PriorityBindingExpression objects. // // See spec at http://avalon/connecteddata/Specs/Data%20Binding.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.ObjectModel; // Collectionusing System.ComponentModel; using System.Globalization; using System.Windows.Markup; using MS.Internal.Data; using MS.Utility; namespace System.Windows.Data { /// /// Describes a collection of bindings attached to a single property. /// These behave as "priority" bindings, meaning that the property /// receives its value from the first binding in the collection that /// can produce a legal value. /// [ContentProperty("Bindings")] public class PriorityBinding : BindingBase, IAddChild { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- ///Constructor public PriorityBinding() : base() { _bindingCollection = new BindingCollection(this, new BindingCollectionChangedCallback(OnBindingCollectionChanged)); } #region IAddChild ////// Called to Add the object as a Child. /// /// /// Object to add as a child - must have type BindingBase /// void IAddChild.AddChild(Object value) { BindingBase binding = value as BindingBase; if (binding != null) Bindings.Add(binding); else throw new ArgumentException(SR.Get(SRID.ChildHasWrongType, this.GetType().Name, "BindingBase", value.GetType().FullName), "value"); } ////// Called when text appears under the tag in markup /// /// /// Text to Add to the Object /// void IAddChild.AddText(string text) { XamlSerializerUtil.ThrowIfNonWhiteSpaceInAddText(text, this); } #endregion IAddChild //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- ///List of inner bindings [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public CollectionBindings { get { return _bindingCollection; } } /// /// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeBindings() { return (Bindings != null && Bindings.Count > 0); } //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ ////// Create an appropriate expression for this Binding, to be attached /// to the given DependencyProperty on the given DependencyObject. /// internal override BindingExpressionBase CreateBindingExpressionOverride(DependencyObject target, DependencyProperty dp, BindingExpressionBase owner) { return PriorityBindingExpression.CreateBindingExpression(target, dp, this, owner); } internal override BindingBase CreateClone() { return new PriorityBinding(); } internal override void InitializeClone(BindingBase baseClone, BindingMode mode) { PriorityBinding clone = (PriorityBinding)baseClone; for (int i=0; i<=_bindingCollection.Count; ++i) { clone._bindingCollection.Add(_bindingCollection[i].Clone(mode)); } base.InitializeClone(baseClone, mode); } private void OnBindingCollectionChanged() { CheckSealed(); } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ BindingCollection _bindingCollection; } } // 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. // // // Description: Defines PriorityBinding object, which stores information // for creating instances of PriorityBindingExpression objects. // // See spec at http://avalon/connecteddata/Specs/Data%20Binding.mht // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Collections.ObjectModel; // Collectionusing System.ComponentModel; using System.Globalization; using System.Windows.Markup; using MS.Internal.Data; using MS.Utility; namespace System.Windows.Data { /// /// Describes a collection of bindings attached to a single property. /// These behave as "priority" bindings, meaning that the property /// receives its value from the first binding in the collection that /// can produce a legal value. /// [ContentProperty("Bindings")] public class PriorityBinding : BindingBase, IAddChild { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- ///Constructor public PriorityBinding() : base() { _bindingCollection = new BindingCollection(this, new BindingCollectionChangedCallback(OnBindingCollectionChanged)); } #region IAddChild ////// Called to Add the object as a Child. /// /// /// Object to add as a child - must have type BindingBase /// void IAddChild.AddChild(Object value) { BindingBase binding = value as BindingBase; if (binding != null) Bindings.Add(binding); else throw new ArgumentException(SR.Get(SRID.ChildHasWrongType, this.GetType().Name, "BindingBase", value.GetType().FullName), "value"); } ////// Called when text appears under the tag in markup /// /// /// Text to Add to the Object /// void IAddChild.AddText(string text) { XamlSerializerUtil.ThrowIfNonWhiteSpaceInAddText(text, this); } #endregion IAddChild //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- ///List of inner bindings [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public CollectionBindings { get { return _bindingCollection; } } /// /// This method is used by TypeDescriptor to determine if this property should /// be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeBindings() { return (Bindings != null && Bindings.Count > 0); } //------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ ////// Create an appropriate expression for this Binding, to be attached /// to the given DependencyProperty on the given DependencyObject. /// internal override BindingExpressionBase CreateBindingExpressionOverride(DependencyObject target, DependencyProperty dp, BindingExpressionBase owner) { return PriorityBindingExpression.CreateBindingExpression(target, dp, this, owner); } internal override BindingBase CreateClone() { return new PriorityBinding(); } internal override void InitializeClone(BindingBase baseClone, BindingMode mode) { PriorityBinding clone = (PriorityBinding)baseClone; for (int i=0; i<=_bindingCollection.Count; ++i) { clone._bindingCollection.Add(_bindingCollection[i].Clone(mode)); } base.InitializeClone(baseClone, mode); } private void OnBindingCollectionChanged() { CheckSealed(); } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ BindingCollection _bindingCollection; } } // 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
- RIPEMD160.cs
- DesignerToolboxInfo.cs
- DataPointer.cs
- CheckableControlBaseAdapter.cs
- GridViewRowEventArgs.cs
- METAHEADER.cs
- OleDbRowUpdatedEvent.cs
- SemaphoreFullException.cs
- Stroke.cs
- XmlSchemaParticle.cs
- TraceContextRecord.cs
- DrawTreeNodeEventArgs.cs
- OneOfConst.cs
- IDReferencePropertyAttribute.cs
- TrackingServices.cs
- BufferedGraphicsContext.cs
- UIElement3D.cs
- Win32SafeHandles.cs
- VerifyHashRequest.cs
- SoapExtensionTypeElement.cs
- WindowsToolbar.cs
- RegistryHandle.cs
- SHA256Managed.cs
- HostingEnvironmentSection.cs
- ContentOperations.cs
- AtomicFile.cs
- NullableIntSumAggregationOperator.cs
- SqlRowUpdatingEvent.cs
- ReaderWriterLock.cs
- Trigger.cs
- PartialArray.cs
- OrderedDictionary.cs
- HasCopySemanticsAttribute.cs
- XmlDocumentViewSchema.cs
- SymmetricCryptoHandle.cs
- CultureInfo.cs
- MenuScrollingVisibilityConverter.cs
- DataGridViewColumnDesigner.cs
- Variable.cs
- WebPartConnectionsEventArgs.cs
- StateMachineAction.cs
- WebPartDisplayModeEventArgs.cs
- FrameworkObject.cs
- SqlInternalConnectionSmi.cs
- InvokeSchedule.cs
- EmbeddedMailObjectCollectionEditor.cs
- PackageRelationshipCollection.cs
- UIElementAutomationPeer.cs
- ExpandableObjectConverter.cs
- Size.cs
- XmlSchemaComplexType.cs
- StyleCollection.cs
- StringCollection.cs
- HelloMessageApril2005.cs
- ProcessHost.cs
- X509ClientCertificateAuthentication.cs
- UnsafeNativeMethods.cs
- RichTextBoxConstants.cs
- Stylus.cs
- VsPropertyGrid.cs
- SqlCacheDependencySection.cs
- WebPartConnectionsConnectVerb.cs
- LocalizabilityAttribute.cs
- ProfessionalColorTable.cs
- SafeMILHandle.cs
- SaveFileDialog.cs
- RectangleGeometry.cs
- BindingsCollection.cs
- GenerateScriptTypeAttribute.cs
- TraceHandlerErrorFormatter.cs
- TypeHelpers.cs
- FileSecurity.cs
- Emitter.cs
- ConfigXmlCDataSection.cs
- METAHEADER.cs
- XmlWriterTraceListener.cs
- FixedSchema.cs
- DSASignatureDeformatter.cs
- ITreeGenerator.cs
- EncodedStreamFactory.cs
- DetailsViewDeleteEventArgs.cs
- SerialPort.cs
- HMACSHA256.cs
- AlphabeticalEnumConverter.cs
- CounterCreationData.cs
- XmlSchemaInferenceException.cs
- ClientScriptManagerWrapper.cs
- ResolveInfo.cs
- WebPartEventArgs.cs
- TableColumn.cs
- InputLangChangeEvent.cs
- WorkflowShape.cs
- Token.cs
- UidManager.cs
- FileIOPermission.cs
- TypeBrowserDialog.cs
- ThreadExceptionEvent.cs
- SecurityState.cs
- _BufferOffsetSize.cs
- DbSetClause.cs