Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Data / PriorityBinding.cs / 1 / 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); } 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); } 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
- CheckableControlBaseAdapter.cs
- CallSiteBinder.cs
- HMAC.cs
- InputScopeManager.cs
- HttpContextServiceHost.cs
- DateBoldEvent.cs
- PngBitmapDecoder.cs
- ElementFactory.cs
- Mouse.cs
- ConditionalExpression.cs
- CellNormalizer.cs
- WebPartDisplayModeEventArgs.cs
- BamlRecordReader.cs
- XmlDocumentFragment.cs
- Compensation.cs
- ErrorTableItemStyle.cs
- InsufficientMemoryException.cs
- WebPartAddingEventArgs.cs
- HttpModulesSection.cs
- SafeProcessHandle.cs
- EdgeModeValidation.cs
- Button.cs
- XmlSerializerObjectSerializer.cs
- QueryCacheKey.cs
- TemplateKey.cs
- ClientScriptManager.cs
- IndexedString.cs
- XPathItem.cs
- RichTextBox.cs
- ProviderConnectionPoint.cs
- ClientUrlResolverWrapper.cs
- PropertyValidationContext.cs
- hwndwrapper.cs
- FillBehavior.cs
- Select.cs
- SqlNotificationRequest.cs
- ExpandSegment.cs
- SystemEvents.cs
- FontStyles.cs
- ParseNumbers.cs
- EventManager.cs
- DecoderNLS.cs
- FileNotFoundException.cs
- DataReceivedEventArgs.cs
- SubclassTypeValidator.cs
- ReferencedAssembly.cs
- DisposableCollectionWrapper.cs
- Bits.cs
- LambdaCompiler.Address.cs
- ImageDrawing.cs
- LocalizableAttribute.cs
- XmlDataLoader.cs
- VersionedStreamOwner.cs
- DataTemplate.cs
- RuleSettings.cs
- TextSelectionHelper.cs
- Activator.cs
- CrossAppDomainChannel.cs
- BindingNavigator.cs
- Debug.cs
- PartialCachingControl.cs
- OptionalColumn.cs
- TextEffectResolver.cs
- DESCryptoServiceProvider.cs
- EnumBuilder.cs
- MembershipSection.cs
- XmlDocumentSerializer.cs
- ScaleTransform3D.cs
- UserNameSecurityTokenParameters.cs
- FontUnit.cs
- ResourceDescriptionAttribute.cs
- ObjectListSelectEventArgs.cs
- TimeSpanValidatorAttribute.cs
- DesignOnlyAttribute.cs
- TraceContext.cs
- Paragraph.cs
- LockedAssemblyCache.cs
- RuleAttributes.cs
- DataGridViewCellEventArgs.cs
- AssemblyBuilderData.cs
- ClientTargetCollection.cs
- AccessViolationException.cs
- RtfToXamlReader.cs
- DataGridState.cs
- AddInContractAttribute.cs
- WorkflowRuntime.cs
- WinInetCache.cs
- ComplexObject.cs
- Annotation.cs
- DataGridViewCellEventArgs.cs
- FamilyTypeface.cs
- SqlXml.cs
- WebPartUtil.cs
- DataObjectMethodAttribute.cs
- TimeIntervalCollection.cs
- SingleResultAttribute.cs
- KeyValuePairs.cs
- ColorComboBox.cs
- XsltContext.cs
- Utils.cs