Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- srgsitem.cs
- ControlPropertyNameConverter.cs
- KeyNotFoundException.cs
- ScriptResourceInfo.cs
- path.cs
- IPCCacheManager.cs
- PropertyEmitterBase.cs
- SourceElementsCollection.cs
- XamlWriter.cs
- GlobalItem.cs
- SecureStringHasher.cs
- DetailsView.cs
- Parser.cs
- CultureTable.cs
- AstNode.cs
- CommonObjectSecurity.cs
- EntityDesignerDataSourceView.cs
- SettingsAttributes.cs
- ResourcePool.cs
- ArgumentNullException.cs
- List.cs
- DataGridViewTextBoxColumn.cs
- control.ime.cs
- ModifierKeysConverter.cs
- HtmlInputImage.cs
- DataColumnMapping.cs
- MimeWriter.cs
- StringBuilder.cs
- ExtensionDataReader.cs
- CodeCompiler.cs
- GacUtil.cs
- ManagedIStream.cs
- GatewayDefinition.cs
- FrameSecurityDescriptor.cs
- EncryptedType.cs
- ValueHandle.cs
- Parser.cs
- SmiXetterAccessMap.cs
- ellipse.cs
- QuaternionAnimation.cs
- ExpressionEditorSheet.cs
- FileSystemEnumerable.cs
- XPathAxisIterator.cs
- DocumentDesigner.cs
- _HeaderInfo.cs
- DataContractSerializerSection.cs
- LineSegment.cs
- MailBnfHelper.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- WebServiceTypeData.cs
- BaseCollection.cs
- ArrayWithOffset.cs
- DriveNotFoundException.cs
- GridItemPattern.cs
- ProtectedConfiguration.cs
- TdsEnums.cs
- XPathNode.cs
- CodeSnippetExpression.cs
- MsmqIntegrationBindingElement.cs
- GeneralTransform.cs
- IsolatedStorageFileStream.cs
- DataColumnChangeEvent.cs
- IRCollection.cs
- SqlDataSourceStatusEventArgs.cs
- BrushConverter.cs
- SystemEvents.cs
- BrowserInteropHelper.cs
- LinkDescriptor.cs
- XmlSchemaExternal.cs
- AdRotator.cs
- Msmq4PoisonHandler.cs
- EmptyEnumerator.cs
- ISAPIRuntime.cs
- DisposableCollectionWrapper.cs
- Error.cs
- CompiledQueryCacheKey.cs
- SchemaTableColumn.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- TableAdapterManagerGenerator.cs
- PeerNameRegistration.cs
- BufferedStream.cs
- StreamMarshaler.cs
- PathParser.cs
- Convert.cs
- ParameterInfo.cs
- BitmapScalingModeValidation.cs
- storepermissionattribute.cs
- ResourceCategoryAttribute.cs
- FontSource.cs
- PenThreadWorker.cs
- RectangleHotSpot.cs
- EntityCollectionChangedParams.cs
- RotationValidation.cs
- PointKeyFrameCollection.cs
- AutoSizeToolBoxItem.cs
- ProcessProtocolHandler.cs
- Model3DGroup.cs
- Permission.cs
- GenericPrincipal.cs
- LineServices.cs