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
- FormsIdentity.cs
- ByteAnimationBase.cs
- Soap12FormatExtensions.cs
- WmpBitmapDecoder.cs
- RelationshipEndMember.cs
- CollectionViewProxy.cs
- UIHelper.cs
- QilChoice.cs
- QueueNameHelper.cs
- AccessorTable.cs
- SourceFileBuildProvider.cs
- UdpDiscoveryEndpoint.cs
- Classification.cs
- ObjectFullSpanRewriter.cs
- COM2EnumConverter.cs
- Helpers.cs
- MessagePropertyVariants.cs
- DataGridSortCommandEventArgs.cs
- CardSpaceException.cs
- SetterBase.cs
- EncoderNLS.cs
- Application.cs
- PageStatePersister.cs
- XmlSchemaSet.cs
- PropertyManager.cs
- WebConfigurationHostFileChange.cs
- ObjectSet.cs
- OutputCache.cs
- Facet.cs
- xsdvalidator.cs
- ProviderSettingsCollection.cs
- XmlText.cs
- MetadataFile.cs
- GridViewCommandEventArgs.cs
- RegexCompiler.cs
- RegexCompilationInfo.cs
- SelectionItemProviderWrapper.cs
- GeneralTransform.cs
- SqlConnectionFactory.cs
- QualificationDataAttribute.cs
- Faults.cs
- WeakKeyDictionary.cs
- XmlSerializerFactory.cs
- Debugger.cs
- Literal.cs
- OdbcConnectionStringbuilder.cs
- Compilation.cs
- FunctionUpdateCommand.cs
- XmlNamespaceMapping.cs
- LoadRetryHandler.cs
- Int16Storage.cs
- ModifyActivitiesPropertyDescriptor.cs
- HotSpot.cs
- basecomparevalidator.cs
- CodeDirectiveCollection.cs
- XmlDataCollection.cs
- AssociationTypeEmitter.cs
- RegistryPermission.cs
- ShadowGlyph.cs
- HttpDebugHandler.cs
- KoreanLunisolarCalendar.cs
- ControlBuilderAttribute.cs
- Switch.cs
- CodePropertyReferenceExpression.cs
- DbReferenceCollection.cs
- SyntaxCheck.cs
- DesignerSerializationVisibilityAttribute.cs
- DataGridColumnReorderingEventArgs.cs
- TdsParserHelperClasses.cs
- RsaSecurityKey.cs
- DockProviderWrapper.cs
- PagedDataSource.cs
- DescendantQuery.cs
- AssemblyAttributes.cs
- StringValueSerializer.cs
- Roles.cs
- XLinq.cs
- RuntimeConfig.cs
- EDesignUtil.cs
- CompilerCollection.cs
- SortableBindingList.cs
- FilterElement.cs
- InputLanguageProfileNotifySink.cs
- RowVisual.cs
- XomlCompilerHelpers.cs
- CustomPeerResolverService.cs
- DocumentOrderComparer.cs
- FieldBuilder.cs
- EndOfStreamException.cs
- ClientEventManager.cs
- TreeNodeCollection.cs
- AncestorChangedEventArgs.cs
- SHA1Managed.cs
- InheritanceRules.cs
- XamlPathDataSerializer.cs
- List.cs
- CollectionCodeDomSerializer.cs
- TranslateTransform.cs
- NullEntityWrapper.cs
- RemotingService.cs