Code:
/ 4.0 / 4.0 / untmp / 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
- Size3D.cs
- Selection.cs
- SymLanguageType.cs
- HwndTarget.cs
- SqlIdentifier.cs
- FacetDescriptionElement.cs
- StorageBasedPackageProperties.cs
- DataTemplate.cs
- SingleResultAttribute.cs
- ShutDownListener.cs
- HtmlInputFile.cs
- DataTableNewRowEvent.cs
- HashMembershipCondition.cs
- TransactionOptions.cs
- TemplateAction.cs
- ContentPlaceHolder.cs
- PlatformCulture.cs
- KeyMatchBuilder.cs
- FileDialog.cs
- ServicePointManagerElement.cs
- NestedContainer.cs
- InputQueueChannelAcceptor.cs
- UnicastIPAddressInformationCollection.cs
- OrderToken.cs
- ScrollItemProviderWrapper.cs
- ValidationRule.cs
- XmlDocumentType.cs
- EUCJPEncoding.cs
- InvalidDocumentContentsException.cs
- XPathNode.cs
- CaseInsensitiveHashCodeProvider.cs
- XmlAttribute.cs
- MatrixCamera.cs
- TextParaLineResult.cs
- EventMappingSettings.cs
- ConfigXmlReader.cs
- HostVisual.cs
- PackageDigitalSignature.cs
- IImplicitResourceProvider.cs
- DataErrorValidationRule.cs
- Helpers.cs
- ConfigXmlDocument.cs
- SQLRoleProvider.cs
- util.cs
- TextElementEnumerator.cs
- SystemColors.cs
- AssemblyCache.cs
- Suspend.cs
- SqlInfoMessageEvent.cs
- BulletedListEventArgs.cs
- SecurityMessageProperty.cs
- documentsequencetextview.cs
- Menu.cs
- HotSpot.cs
- StringSorter.cs
- PaginationProgressEventArgs.cs
- MetaModel.cs
- CultureInfoConverter.cs
- PropertyToken.cs
- WebAdminConfigurationHelper.cs
- PrinterSettings.cs
- _Win32.cs
- PropertyDescriptorComparer.cs
- AffineTransform3D.cs
- BitmapEncoder.cs
- NeutralResourcesLanguageAttribute.cs
- TypeValidationEventArgs.cs
- SqlConnectionString.cs
- ForwardPositionQuery.cs
- OAVariantLib.cs
- ConfigurationManagerInternalFactory.cs
- ItemTypeToolStripMenuItem.cs
- Lasso.cs
- MimeTypeAttribute.cs
- PublisherIdentityPermission.cs
- XslCompiledTransform.cs
- EasingKeyFrames.cs
- WebPartManager.cs
- SelectionEditingBehavior.cs
- ClientProxyGenerator.cs
- ComponentFactoryHelpers.cs
- VBCodeProvider.cs
- ReflectPropertyDescriptor.cs
- Header.cs
- AttributeCollection.cs
- ZoneMembershipCondition.cs
- BufferedWebEventProvider.cs
- WebRequestModuleElement.cs
- Root.cs
- PartialCachingAttribute.cs
- TimeSpanValidatorAttribute.cs
- ObjectView.cs
- OperandQuery.cs
- InvalidDocumentContentsException.cs
- DispatchWrapper.cs
- CategoryAttribute.cs
- RedistVersionInfo.cs
- PageStatePersister.cs
- Rectangle.cs
- ThreadExceptionEvent.cs