Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- VersionPair.cs
- AmbientLight.cs
- SiteMapDesignerDataSourceView.cs
- RightsManagementProvider.cs
- Control.cs
- FloatUtil.cs
- GroupBox.cs
- WindowPatternIdentifiers.cs
- ImmComposition.cs
- StylusTouchDevice.cs
- DataGridViewCellStyleConverter.cs
- HttpChannelFactory.cs
- ValidatorUtils.cs
- LogWriteRestartAreaAsyncResult.cs
- SecurityContextKeyIdentifierClause.cs
- Types.cs
- DbConnectionFactory.cs
- TextOutput.cs
- FormCollection.cs
- SettingsPropertyValueCollection.cs
- RemotingSurrogateSelector.cs
- QualificationDataAttribute.cs
- DockingAttribute.cs
- GenericXmlSecurityToken.cs
- EventManager.cs
- PointConverter.cs
- ExtendedProperty.cs
- XmlSchemaSimpleTypeRestriction.cs
- Matrix3DStack.cs
- iisPickupDirectory.cs
- ClientTargetSection.cs
- BitmapEffectInputConnector.cs
- DataServiceHost.cs
- NodeInfo.cs
- IndentTextWriter.cs
- PagesSection.cs
- Rfc2898DeriveBytes.cs
- SaveFileDialog.cs
- ProviderUtil.cs
- SafeFileMappingHandle.cs
- CompressedStack.cs
- NavigationWindowAutomationPeer.cs
- LinkedList.cs
- MimeTypeAttribute.cs
- SimpleApplicationHost.cs
- DataGridViewCellStyle.cs
- QuadraticBezierSegment.cs
- DynamicRendererThreadManager.cs
- CounterCreationDataCollection.cs
- FunctionUpdateCommand.cs
- XmlSchemaIdentityConstraint.cs
- LineMetrics.cs
- HandleCollector.cs
- MsdtcClusterUtils.cs
- SafeRightsManagementEnvironmentHandle.cs
- ProgressPage.cs
- KeyValuePairs.cs
- WpfSharedBamlSchemaContext.cs
- ToolStripProgressBar.cs
- ControllableStoryboardAction.cs
- ProfessionalColorTable.cs
- OutOfProcStateClientManager.cs
- NestPullup.cs
- Pair.cs
- DivideByZeroException.cs
- CompilerState.cs
- basevalidator.cs
- CryptoConfig.cs
- TypeToken.cs
- StrokeIntersection.cs
- ObjectToken.cs
- BitVector32.cs
- ParseChildrenAsPropertiesAttribute.cs
- TextTreeInsertElementUndoUnit.cs
- Normalization.cs
- BinaryWriter.cs
- RotateTransform3D.cs
- MasterPageCodeDomTreeGenerator.cs
- WmpBitmapDecoder.cs
- UIInitializationException.cs
- AffineTransform3D.cs
- PersonalizableAttribute.cs
- ColumnHeader.cs
- Binding.cs
- TextElementEnumerator.cs
- SqlTransaction.cs
- Context.cs
- IConvertible.cs
- StateMachineHelpers.cs
- PersonalizationProviderHelper.cs
- WebSysDefaultValueAttribute.cs
- PropertyToken.cs
- Pair.cs
- FilterQuery.cs
- TypedRowGenerator.cs
- TextFragmentEngine.cs
- DispatchWrapper.cs
- AttributeExtensions.cs
- TraceLog.cs
- GraphicsPath.cs