Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Controls / AlternationConverter.cs / 1 / 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
- SchemaSetCompiler.cs
- OleDbCommand.cs
- ConfigXmlComment.cs
- SqlDataSource.cs
- WebScriptEnablingElement.cs
- ZoneIdentityPermission.cs
- SafeFindHandle.cs
- SafeRightsManagementQueryHandle.cs
- ManagedIStream.cs
- HttpConfigurationSystem.cs
- ConstraintConverter.cs
- QueryValue.cs
- XPathParser.cs
- SamlAttribute.cs
- EmptyEnumerator.cs
- TreeNodeSelectionProcessor.cs
- TypeConverterBase.cs
- XmlSecureResolver.cs
- GroupItemAutomationPeer.cs
- SharedHttpsTransportManager.cs
- SubstitutionList.cs
- Scalars.cs
- OleDbCommandBuilder.cs
- ClientBuildManager.cs
- Version.cs
- FormViewInsertedEventArgs.cs
- Parameter.cs
- ArrangedElement.cs
- DnsPermission.cs
- CodeAssignStatement.cs
- GenericParameterDataContract.cs
- TableItemPattern.cs
- SQLCharsStorage.cs
- DbUpdateCommandTree.cs
- ManipulationDevice.cs
- cookie.cs
- RenderingEventArgs.cs
- DataGridViewRowHeaderCell.cs
- CompiledQuery.cs
- StringHandle.cs
- TileBrush.cs
- XmlWhitespace.cs
- MessagePartProtectionMode.cs
- SiteMapNodeCollection.cs
- Base64Decoder.cs
- VisualTreeUtils.cs
- EventWaitHandle.cs
- MailMessageEventArgs.cs
- DataReaderContainer.cs
- filewebrequest.cs
- CrossAppDomainChannel.cs
- RightNameExpirationInfoPair.cs
- DataSet.cs
- WindowsGraphics2.cs
- SafeEventLogWriteHandle.cs
- BamlRecords.cs
- Bitmap.cs
- ReadOnlyMetadataCollection.cs
- DataGridViewCellLinkedList.cs
- NonVisualControlAttribute.cs
- TriState.cs
- SmtpNegotiateAuthenticationModule.cs
- ObjectDataSourceView.cs
- CacheDependency.cs
- FixedFindEngine.cs
- ClientSideQueueItem.cs
- PropertyItem.cs
- DropShadowBitmapEffect.cs
- SqlDataSourceSelectingEventArgs.cs
- UnaryNode.cs
- SamlAudienceRestrictionCondition.cs
- VirtualDirectoryMapping.cs
- ObjectDisposedException.cs
- ImageSource.cs
- CharacterMetrics.cs
- EmbossBitmapEffect.cs
- IntegerFacetDescriptionElement.cs
- RemoveStoryboard.cs
- DiscoveryReferences.cs
- GacUtil.cs
- recordstatescratchpad.cs
- LinkUtilities.cs
- QueryCursorEventArgs.cs
- FormViewRow.cs
- LogLogRecord.cs
- RSAOAEPKeyExchangeDeformatter.cs
- TextTreeRootNode.cs
- ContainerActivationHelper.cs
- EntityDataSourceValidationException.cs
- RtfControlWordInfo.cs
- LinkArea.cs
- DerivedKeySecurityToken.cs
- AudioBase.cs
- ClientClassGenerator.cs
- SerializationInfoEnumerator.cs
- PreviewPrintController.cs
- NumberFunctions.cs
- PanelContainerDesigner.cs
- SqlDependencyListener.cs
- MultipleViewPattern.cs