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
- DynamicResourceExtension.cs
- QilXmlWriter.cs
- ProviderCollection.cs
- FormatPage.cs
- PackWebRequest.cs
- DataSourceExpression.cs
- WebMessageFormatHelper.cs
- TextDecorations.cs
- UnsafeNetInfoNativeMethods.cs
- XmlNamespaceMappingCollection.cs
- CollectionsUtil.cs
- ImportException.cs
- SchemaMerger.cs
- ConfigXmlElement.cs
- BinaryObjectReader.cs
- updatecommandorderer.cs
- CodeDOMUtility.cs
- TypeResolvingOptions.cs
- PresentationAppDomainManager.cs
- PersistChildrenAttribute.cs
- BaseTransportHeaders.cs
- X509UI.cs
- FontWeights.cs
- AppDomainUnloadedException.cs
- PersonalizationProvider.cs
- HttpCachePolicyElement.cs
- MediaPlayer.cs
- FormsAuthenticationModule.cs
- ScrollProviderWrapper.cs
- SwitchAttribute.cs
- CopyOnWriteList.cs
- GregorianCalendar.cs
- ImmComposition.cs
- ToolBarButtonClickEvent.cs
- GridItemCollection.cs
- RowVisual.cs
- ApplicationFileCodeDomTreeGenerator.cs
- SelectingProviderEventArgs.cs
- ArgumentNullException.cs
- BaseHashHelper.cs
- NonPrimarySelectionGlyph.cs
- RangeEnumerable.cs
- EnvironmentPermission.cs
- OleDbRowUpdatedEvent.cs
- EventLogReader.cs
- XmlWrappingReader.cs
- SelectionWordBreaker.cs
- InfoCardBaseException.cs
- SamlAuthorizationDecisionStatement.cs
- MethodImplAttribute.cs
- EdmMember.cs
- XmlAttributeCollection.cs
- CompositeControl.cs
- ImpersonateTokenRef.cs
- MimeAnyImporter.cs
- ImageConverter.cs
- NullableIntAverageAggregationOperator.cs
- WebPartTracker.cs
- ProtectedConfigurationProviderCollection.cs
- DeviceSpecificChoiceCollection.cs
- Visual3D.cs
- StylusPlugInCollection.cs
- QueryOperator.cs
- WindowsRichEdit.cs
- HierarchicalDataBoundControlAdapter.cs
- SQLMembershipProvider.cs
- ProfilePropertySettingsCollection.cs
- ConnectionPoolRegistry.cs
- ComponentManagerBroker.cs
- TextElementEnumerator.cs
- RectValueSerializer.cs
- EntityTypeBase.cs
- DataServiceRequestOfT.cs
- WebHttpEndpointElement.cs
- Control.cs
- TreeNodeCollection.cs
- FieldDescriptor.cs
- Mutex.cs
- FixedSOMPageElement.cs
- MachineKeySection.cs
- ReferenceAssemblyAttribute.cs
- ToolTip.cs
- GacUtil.cs
- StringSorter.cs
- PagedDataSource.cs
- EncryptedXml.cs
- XmlSignatureManifest.cs
- ProtectedConfiguration.cs
- AuditLevel.cs
- Bezier.cs
- MaskedTextProvider.cs
- BrowserTree.cs
- ClientProxyGenerator.cs
- WriteTimeStream.cs
- SetterBase.cs
- CollectionType.cs
- WebPartZone.cs
- XmlReader.cs
- _ContextAwareResult.cs
- ConnectorMovedEventArgs.cs