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
- QilValidationVisitor.cs
- NativeMethods.cs
- SimpleWorkerRequest.cs
- Typography.cs
- DebuggerAttributes.cs
- LoadRetryAsyncResult.cs
- TargetInvocationException.cs
- TextEffectResolver.cs
- CTreeGenerator.cs
- Module.cs
- InstancePersistenceCommandException.cs
- DynamicDataExtensions.cs
- PageContentAsyncResult.cs
- ListItemCollection.cs
- Variant.cs
- CachingHintValidation.cs
- DbReferenceCollection.cs
- MessageHeaderInfoTraceRecord.cs
- GroupLabel.cs
- ByteRangeDownloader.cs
- XmlSchemaCollection.cs
- Preprocessor.cs
- UnaryNode.cs
- MasterPage.cs
- StorageTypeMapping.cs
- SqlMethods.cs
- ZipIOLocalFileHeader.cs
- TrayIconDesigner.cs
- ConsoleKeyInfo.cs
- FolderNameEditor.cs
- ControlPropertyNameConverter.cs
- TypeConverterValueSerializer.cs
- WebBaseEventKeyComparer.cs
- ThicknessAnimationBase.cs
- ClickablePoint.cs
- SettingsPropertyValue.cs
- WindowsFormsDesignerOptionService.cs
- FastEncoder.cs
- AdornerPresentationContext.cs
- ComPlusAuthorization.cs
- EventPropertyMap.cs
- DebugHandleTracker.cs
- Win32KeyboardDevice.cs
- KeyedHashAlgorithm.cs
- ReaderOutput.cs
- TimeManager.cs
- GPPOINT.cs
- SHA1Managed.cs
- QueryConverter.cs
- ExceptionUtil.cs
- PrintControllerWithStatusDialog.cs
- ListenDesigner.cs
- BindableAttribute.cs
- LayoutEngine.cs
- DefaultPrintController.cs
- ToolStripCollectionEditor.cs
- HwndMouseInputProvider.cs
- TdsParserStaticMethods.cs
- BindingUtils.cs
- Int32Storage.cs
- ILGenerator.cs
- MissingFieldException.cs
- SessionState.cs
- DataGridViewIntLinkedList.cs
- TemplateField.cs
- XsdBuildProvider.cs
- ControlValuePropertyAttribute.cs
- AnnotationResourceCollection.cs
- ButtonField.cs
- LoopExpression.cs
- XmlArrayItemAttribute.cs
- UnionExpr.cs
- MobileControlBuilder.cs
- ChangeNode.cs
- CollectionsUtil.cs
- PageRequestManager.cs
- Hashtable.cs
- prefixendpointaddressmessagefiltertable.cs
- HttpFormatExtensions.cs
- VirtualizingPanel.cs
- EmbossBitmapEffect.cs
- AuthorizationRule.cs
- RewritingProcessor.cs
- XPathNavigator.cs
- IsolatedStorageFilePermission.cs
- Int16.cs
- GridViewUpdateEventArgs.cs
- TriggerBase.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- XslCompiledTransform.cs
- ReadOnlyPermissionSet.cs
- OdbcParameterCollection.cs
- TagNameToTypeMapper.cs
- AnonymousIdentificationModule.cs
- CustomErrorCollection.cs
- OleDbException.cs
- ComponentEditorPage.cs
- ObjectDataSource.cs
- XmlSchemaException.cs
- FontFamily.cs