Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- RoutedEventConverter.cs
- DebugHandleTracker.cs
- HtmlInputControl.cs
- CallContext.cs
- DiagnosticsConfigurationHandler.cs
- ResourceDescriptionAttribute.cs
- Marshal.cs
- DataChangedEventManager.cs
- MimeObjectFactory.cs
- TypeExtensionConverter.cs
- TraceEventCache.cs
- ColorInterpolationModeValidation.cs
- StorageMappingFragment.cs
- OracleBoolean.cs
- TextParagraphProperties.cs
- HttpAsyncResult.cs
- RegexFCD.cs
- followingquery.cs
- DefaultAssemblyResolver.cs
- CustomAttributeFormatException.cs
- AttributeQuery.cs
- BitmapCache.cs
- RadioButtonList.cs
- BigInt.cs
- DSASignatureFormatter.cs
- ServiceKnownTypeAttribute.cs
- ClrPerspective.cs
- XmlAtomicValue.cs
- TableItemStyle.cs
- SchemaObjectWriter.cs
- userdatakeys.cs
- TraceData.cs
- PrinterUnitConvert.cs
- SubMenuStyle.cs
- GeometryCollection.cs
- AccessibilityApplicationManager.cs
- ToolStripDropTargetManager.cs
- ADMembershipProvider.cs
- GetReadStreamResult.cs
- DbConnectionPoolGroupProviderInfo.cs
- ValuePatternIdentifiers.cs
- ColumnHeaderConverter.cs
- TypefaceMap.cs
- WSHttpTransportSecurityElement.cs
- PeerContact.cs
- HttpConfigurationSystem.cs
- TypeDescriptionProvider.cs
- RemoteCryptoSignHashRequest.cs
- _HeaderInfo.cs
- TraceLevelStore.cs
- HMACRIPEMD160.cs
- XmlDictionaryReader.cs
- XmlKeywords.cs
- AnnotationAdorner.cs
- EmptyStringExpandableObjectConverter.cs
- SchemaElementLookUpTable.cs
- MemberJoinTreeNode.cs
- DropTarget.cs
- ProcessModelInfo.cs
- Object.cs
- CollectionDataContractAttribute.cs
- ButtonColumn.cs
- OleDbFactory.cs
- SqlDataSourceCache.cs
- DynamicEntity.cs
- InkPresenter.cs
- DependencyPropertyConverter.cs
- Deserializer.cs
- TypographyProperties.cs
- PointCollectionValueSerializer.cs
- NeutralResourcesLanguageAttribute.cs
- EventMappingSettingsCollection.cs
- HeaderUtility.cs
- ToolStripItemBehavior.cs
- LinearGradientBrush.cs
- AsymmetricSecurityBindingElement.cs
- AspCompat.cs
- NotifyIcon.cs
- UnsafePeerToPeerMethods.cs
- SupportsPreviewControlAttribute.cs
- SQLGuidStorage.cs
- WebPartConnectionsConnectVerb.cs
- NetNamedPipeBindingElement.cs
- XslTransform.cs
- InstanceOwnerException.cs
- SetUserPreferenceRequest.cs
- DefaultTraceListener.cs
- Int32Collection.cs
- PageStatePersister.cs
- DataGridViewCellMouseEventArgs.cs
- XpsTokenContext.cs
- SecurityKeyIdentifierClause.cs
- HttpStreamXmlDictionaryReader.cs
- EventLogPermission.cs
- VirtualPathProvider.cs
- WindowsPen.cs
- ProviderBase.cs
- GorillaCodec.cs
- CodeExpressionStatement.cs
- DataGridViewImageColumn.cs