Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / AlternationConverter.cs / 1305600 / AlternationConverter.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) by Microsoft Corporation. All rights reserved.
//
//
// Description: Convert between index and a list of values.
//
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;
namespace System.Windows.Controls
{
///
/// AlternationConverter is intended to be used by a binding to the
/// ItemsControl.AlternationIndex attached property. It converts an integer
/// into the corresponding item in Values list.
///
[ContentProperty("Values")]
public class AlternationConverter : IValueConverter
{
///
/// A list of values.
///
public IList Values
{
get { return _values; }
}
///
/// Convert an integer to the corresponding value from the Values list.
///
public object Convert (object o, Type targetType, object parameter, CultureInfo culture)
{
if (_values.Count > 0 && o is int)
{
int index = ((int)o) % _values.Count;
if (index < 0) // Adjust for incorrect definition of the %-operator for negative arguments.
index += _values.Count;
return _values[index];
}
return DependencyProperty.UnsetValue;
}
///
/// Convert an object to the index in the Values list at which that object appears.
/// If the object is not in the Values list, return -1.
///
public object ConvertBack(object o, Type targetType, object parameter, CultureInfo culture)
{
return _values.IndexOf(o);
}
List
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlNotificationEventArgs.cs
- QuotedStringFormatReader.cs
- TransactionInformation.cs
- ChtmlPhoneCallAdapter.cs
- OdbcConnectionHandle.cs
- ProfileProvider.cs
- XmlSerializerFactory.cs
- DesignTimeData.cs
- _BaseOverlappedAsyncResult.cs
- XmlDictionaryReader.cs
- CssClassPropertyAttribute.cs
- NamespaceInfo.cs
- ServiceModelEnhancedConfigurationElementCollection.cs
- HttpException.cs
- OpCopier.cs
- HiddenFieldPageStatePersister.cs
- _ListenerRequestStream.cs
- UnitySerializationHolder.cs
- KeyGesture.cs
- ExpressionBuilder.cs
- WindowPatternIdentifiers.cs
- DesignerProperties.cs
- TextProperties.cs
- FactoryId.cs
- DoubleAnimationBase.cs
- ViewValidator.cs
- ConfigXmlAttribute.cs
- ConfigurationElement.cs
- NeutralResourcesLanguageAttribute.cs
- Executor.cs
- FontUnitConverter.cs
- AccessibilityApplicationManager.cs
- BindableAttribute.cs
- HTMLTextWriter.cs
- Table.cs
- UniqueID.cs
- SigningCredentials.cs
- PropertyGeneratedEventArgs.cs
- HashLookup.cs
- Input.cs
- DataGridRowHeader.cs
- FixedFlowMap.cs
- BitmapCodecInfoInternal.cs
- KeyProperty.cs
- DataChangedEventManager.cs
- SwitchLevelAttribute.cs
- CodeAttributeArgumentCollection.cs
- HttpAsyncResult.cs
- XomlCompilerError.cs
- controlskin.cs
- CachedBitmap.cs
- Row.cs
- CFStream.cs
- ConfigXmlCDataSection.cs
- ScrollableControlDesigner.cs
- IDataContractSurrogate.cs
- ColorMatrix.cs
- XmlDataCollection.cs
- arclist.cs
- FieldNameLookup.cs
- DebugHandleTracker.cs
- BasicDesignerLoader.cs
- MatrixTransform.cs
- PointLight.cs
- CodeDirectiveCollection.cs
- DeploymentSection.cs
- SignedPkcs7.cs
- WindowsFormsLinkLabel.cs
- TextChange.cs
- PersonalizationStateQuery.cs
- Int64Converter.cs
- DecimalMinMaxAggregationOperator.cs
- MainMenu.cs
- DeploymentSection.cs
- NameObjectCollectionBase.cs
- UserControl.cs
- ImportOptions.cs
- PackageRelationshipSelector.cs
- PathFigureCollectionValueSerializer.cs
- FixedStringLookup.cs
- ApplicationFileParser.cs
- ToolStripDropDown.cs
- LocalizabilityAttribute.cs
- FilterFactory.cs
- Style.cs
- DataServiceContext.cs
- RenderDataDrawingContext.cs
- RepeaterItemEventArgs.cs
- WSSecurityOneDotZeroSendSecurityHeader.cs
- CacheForPrimitiveTypes.cs
- DataSetUtil.cs
- XmlHelper.cs
- TextEncodedRawTextWriter.cs
- validation.cs
- EntryWrittenEventArgs.cs
- SqlNotificationRequest.cs
- UpdateManifestForBrowserApplication.cs
- ReadOnlyDataSource.cs
- SR.cs
- Missing.cs