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
- ZipIOLocalFileDataDescriptor.cs
- DiscoveryReference.cs
- ElementMarkupObject.cs
- Roles.cs
- WebPartEditVerb.cs
- MarkupProperty.cs
- SettingsAttributes.cs
- AlphaSortedEnumConverter.cs
- ConnectionManagementElementCollection.cs
- AspNetCompatibilityRequirementsMode.cs
- SrgsElementFactoryCompiler.cs
- LinqDataSourceValidationException.cs
- elementinformation.cs
- NumberEdit.cs
- GridErrorDlg.cs
- DataServiceProcessingPipeline.cs
- DesignerTransaction.cs
- MetafileHeaderWmf.cs
- transactioncontext.cs
- DataGridViewTopLeftHeaderCell.cs
- StandardToolWindows.cs
- Visitor.cs
- TextTreeInsertElementUndoUnit.cs
- PropertyValueChangedEvent.cs
- DataGridPageChangedEventArgs.cs
- WebPartDeleteVerb.cs
- WorkflowOwnershipException.cs
- ChooseAction.cs
- FormattedText.cs
- AudienceUriMode.cs
- ContentTextAutomationPeer.cs
- SchemaMapping.cs
- HtmlElementErrorEventArgs.cs
- ExecutedRoutedEventArgs.cs
- WebPartEditorCancelVerb.cs
- XpsFilter.cs
- ProviderIncompatibleException.cs
- MemoryMappedFileSecurity.cs
- XamlPoint3DCollectionSerializer.cs
- NativeMsmqMessage.cs
- Decorator.cs
- HashSetDebugView.cs
- PathTooLongException.cs
- GridItemCollection.cs
- InfiniteIntConverter.cs
- GenerateScriptTypeAttribute.cs
- IgnoreDataMemberAttribute.cs
- MasterPageCodeDomTreeGenerator.cs
- InertiaExpansionBehavior.cs
- ZipPackage.cs
- ConnectorMovedEventArgs.cs
- PlatformNotSupportedException.cs
- DataTableTypeConverter.cs
- TransformerTypeCollection.cs
- Lease.cs
- BaseAddressElementCollection.cs
- ReadWriteSpinLock.cs
- EventProviderWriter.cs
- EllipseGeometry.cs
- JsonEncodingStreamWrapper.cs
- HttpListenerResponse.cs
- CommentGlyph.cs
- WindowInteropHelper.cs
- CodePageEncoding.cs
- TransformerTypeCollection.cs
- ResourcePart.cs
- MediaContextNotificationWindow.cs
- XPathException.cs
- LoginViewDesigner.cs
- ViewEventArgs.cs
- TextProperties.cs
- ObjectQueryProvider.cs
- PeerCustomResolverElement.cs
- SetterBase.cs
- CommentEmitter.cs
- DataPagerFieldCommandEventArgs.cs
- SchemaInfo.cs
- EffectiveValueEntry.cs
- GridViewCellAutomationPeer.cs
- ExpandSegmentCollection.cs
- FullTextState.cs
- Operators.cs
- UpdatePanelTriggerCollection.cs
- XLinq.cs
- IndexedDataBuffer.cs
- XmlILOptimizerVisitor.cs
- CompiledQueryCacheKey.cs
- QueryContinueDragEvent.cs
- SqlMethodAttribute.cs
- XsltSettings.cs
- WindowsListViewScroll.cs
- SQlBooleanStorage.cs
- Brush.cs
- TypeExtensionConverter.cs
- ColorKeyFrameCollection.cs
- SourceFilter.cs
- PrintDocument.cs
- ViewStateModeByIdAttribute.cs
- InternalConfigConfigurationFactory.cs
- _ContextAwareResult.cs