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
- ServiceModelStringsVersion1.cs
- DiscoveryOperationContextExtension.cs
- SqlWorkflowInstanceStore.cs
- HttpsChannelListener.cs
- SafeSecurityHandles.cs
- EventLogger.cs
- Vector3DValueSerializer.cs
- ConnectionManagementElement.cs
- AnnotationObservableCollection.cs
- HtmlInputText.cs
- Operator.cs
- AutomationIdentifier.cs
- OdbcConnectionHandle.cs
- SupportsEventValidationAttribute.cs
- SmiMetaDataProperty.cs
- GregorianCalendarHelper.cs
- DrawingAttributes.cs
- CounterNameConverter.cs
- AliasExpr.cs
- MimeTypeAttribute.cs
- Expression.cs
- AutomationPropertyInfo.cs
- ListItemCollection.cs
- PlanCompiler.cs
- PageWrapper.cs
- Constraint.cs
- Separator.cs
- BlockCollection.cs
- DesignerSerializationVisibilityAttribute.cs
- DTCTransactionManager.cs
- WebRequestModuleElement.cs
- PropertyManager.cs
- SymLanguageType.cs
- DataGridViewCell.cs
- ActiveXHelper.cs
- AsyncSerializedWorker.cs
- SerializerWriterEventHandlers.cs
- DataFormats.cs
- EntityReference.cs
- IdleTimeoutMonitor.cs
- URLIdentityPermission.cs
- XamlToRtfParser.cs
- CommandValueSerializer.cs
- SizeFConverter.cs
- ContentType.cs
- Vector3dCollection.cs
- QilLiteral.cs
- TextEffectResolver.cs
- WSHttpBindingCollectionElement.cs
- TcpSocketManager.cs
- LicenseContext.cs
- FlatButtonAppearance.cs
- TemplatePagerField.cs
- StrokeNodeOperations2.cs
- SynchronizationContext.cs
- TypeDependencyAttribute.cs
- DynamicMethod.cs
- PagesSection.cs
- XamlTreeBuilder.cs
- RequestCachePolicyConverter.cs
- TextDocumentView.cs
- SessionStateSection.cs
- xml.cs
- MulticastDelegate.cs
- XmlChildNodes.cs
- Accessible.cs
- RunWorkerCompletedEventArgs.cs
- OpenTypeLayoutCache.cs
- ExpandoObject.cs
- Decoder.cs
- WindowsImpersonationContext.cs
- SqlServer2KCompatibilityAnnotation.cs
- PipelineModuleStepContainer.cs
- IsolatedStorage.cs
- CriticalExceptions.cs
- DesignBindingPropertyDescriptor.cs
- AbstractExpressions.cs
- SortKey.cs
- NetworkInformationException.cs
- RegularExpressionValidator.cs
- RemotingConfigParser.cs
- CriticalHandle.cs
- BooleanKeyFrameCollection.cs
- PropertyMetadata.cs
- ExternalDataExchangeService.cs
- Size.cs
- WebPartChrome.cs
- PnrpPermission.cs
- ObfuscationAttribute.cs
- XPathNodeInfoAtom.cs
- XPathSingletonIterator.cs
- control.ime.cs
- ClusterRegistryConfigurationProvider.cs
- NotifyIcon.cs
- BezierSegment.cs
- MetadataUtilsSmi.cs
- ViewUtilities.cs
- CompiledAction.cs
- CompilationPass2Task.cs
- BookmarkScopeManager.cs