Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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; // Collection
using 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 Collection Bindings
{
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; // Collection
using 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 Collection Bindings
{
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
- TraceInternal.cs
- StorageConditionPropertyMapping.cs
- HtmlString.cs
- SpellerStatusTable.cs
- NestedContainer.cs
- CharacterMetricsDictionary.cs
- Point3D.cs
- BrushValueSerializer.cs
- ArrayWithOffset.cs
- WebMessageEncodingElement.cs
- WebScriptMetadataMessage.cs
- Intellisense.cs
- ProjectionCamera.cs
- ProxyManager.cs
- StringResourceManager.cs
- TabItemWrapperAutomationPeer.cs
- GeometryDrawing.cs
- TypeDescriptor.cs
- DeviceOverridableAttribute.cs
- NavigationPropertySingletonExpression.cs
- WindowExtensionMethods.cs
- RepeatBehaviorConverter.cs
- FileSecurity.cs
- SizeAnimationBase.cs
- WorkflowRuntimeService.cs
- BooleanToVisibilityConverter.cs
- TransformerConfigurationWizardBase.cs
- EventLogEntryCollection.cs
- DataReceivedEventArgs.cs
- Compress.cs
- SqlVersion.cs
- CollectionType.cs
- KeyInfo.cs
- HelpKeywordAttribute.cs
- RangeBase.cs
- FrameworkReadOnlyPropertyMetadata.cs
- SigningCredentials.cs
- ContentPresenter.cs
- ObfuscationAttribute.cs
- ListViewContainer.cs
- VisualStyleRenderer.cs
- GridViewRowCollection.cs
- DataGridViewCellCancelEventArgs.cs
- SelectorAutomationPeer.cs
- XPathExpr.cs
- Set.cs
- ConfigPathUtility.cs
- StringUtil.cs
- SessionSwitchEventArgs.cs
- NamespaceCollection.cs
- ParameterCollection.cs
- XmlSchemaSimpleContentExtension.cs
- SHA1CryptoServiceProvider.cs
- TextEffect.cs
- VectorCollection.cs
- AccessControlEntry.cs
- DbProviderFactoriesConfigurationHandler.cs
- _SSPIWrapper.cs
- WebPartConnectionsConfigureVerb.cs
- GridViewSortEventArgs.cs
- LineSegment.cs
- HttpResponseWrapper.cs
- SetterBase.cs
- XamlSerializer.cs
- PathParser.cs
- PolicyException.cs
- FormatConvertedBitmap.cs
- XhtmlBasicObjectListAdapter.cs
- DocumentSequence.cs
- ValidationResult.cs
- HttpModuleActionCollection.cs
- GridViewSelectEventArgs.cs
- Message.cs
- RoleManagerSection.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- SR.Designer.cs
- UnmanagedMemoryStreamWrapper.cs
- ListViewInsertedEventArgs.cs
- ComplexType.cs
- DataGridViewRow.cs
- IfJoinedCondition.cs
- TextCharacters.cs
- SoapFault.cs
- processwaithandle.cs
- HttpWriter.cs
- WasHttpHandlersInstallComponent.cs
- HMACSHA1.cs
- ObjectItemConventionAssemblyLoader.cs
- EmissiveMaterial.cs
- BooleanSwitch.cs
- FocusTracker.cs
- SettingsPropertyValueCollection.cs
- IIS7WorkerRequest.cs
- ContextStaticAttribute.cs
- XsltConvert.cs
- UDPClient.cs
- BuildManagerHost.cs
- StateDesigner.Helpers.cs
- ResourceReferenceExpressionConverter.cs
- SimpleWorkerRequest.cs