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
- HasCopySemanticsAttribute.cs
- SettingsBase.cs
- Ref.cs
- BypassElement.cs
- HttpVersion.cs
- Positioning.cs
- SqlDataReaderSmi.cs
- LicenseException.cs
- WebColorConverter.cs
- ContentPlaceHolderDesigner.cs
- CodeCatchClause.cs
- ExpressionsCollectionConverter.cs
- JobInputBins.cs
- EntityDataSourceUtil.cs
- RowType.cs
- TemplatedMailWebEventProvider.cs
- RijndaelManagedTransform.cs
- NavigationProperty.cs
- GeneralTransformGroup.cs
- _CacheStreams.cs
- RijndaelCryptoServiceProvider.cs
- TraceEventCache.cs
- NonBatchDirectoryCompiler.cs
- InvokeMethodActivity.cs
- JumpList.cs
- ForeignKeyFactory.cs
- rsa.cs
- EntitySqlQueryState.cs
- ObfuscateAssemblyAttribute.cs
- DrawListViewSubItemEventArgs.cs
- ConfigPathUtility.cs
- Token.cs
- CallbackHandler.cs
- XmlBaseWriter.cs
- ProviderException.cs
- BitmapCodecInfo.cs
- SystemFonts.cs
- Lasso.cs
- Lease.cs
- MenuItemCollection.cs
- XPathNavigatorKeyComparer.cs
- HtmlAnchor.cs
- ClockController.cs
- ServiceOperation.cs
- DotAtomReader.cs
- Object.cs
- SiteMapPath.cs
- BitmapEffectInput.cs
- TransformerTypeCollection.cs
- XmlCharacterData.cs
- AuthenticatedStream.cs
- StrongNameMembershipCondition.cs
- TextTreeRootTextBlock.cs
- SmiRecordBuffer.cs
- DefaultValueAttribute.cs
- ProfileSettingsCollection.cs
- IImplicitResourceProvider.cs
- __FastResourceComparer.cs
- PeerToPeerException.cs
- EmptyElement.cs
- Configuration.cs
- ListViewItemMouseHoverEvent.cs
- TerminateSequence.cs
- PropertyGridView.cs
- ParserHooks.cs
- EncodingDataItem.cs
- PaperSource.cs
- coordinator.cs
- RootNamespaceAttribute.cs
- PersonalizableAttribute.cs
- MobileControlBuilder.cs
- FontUnit.cs
- RelatedView.cs
- KeyFrames.cs
- TextPattern.cs
- CurrentTimeZone.cs
- DesignerAdRotatorAdapter.cs
- TextBoxRenderer.cs
- SrgsText.cs
- SQLBoolean.cs
- SchemaImporterExtensionElementCollection.cs
- X509UI.cs
- SettingsPropertyNotFoundException.cs
- NavigationService.cs
- DataServiceHost.cs
- XmlKeywords.cs
- ECDsa.cs
- DSACryptoServiceProvider.cs
- MetadataPropertyCollection.cs
- PropertyItem.cs
- RangeContentEnumerator.cs
- returneventsaver.cs
- SerializationSectionGroup.cs
- StoreConnection.cs
- IntSecurity.cs
- RegexInterpreter.cs
- HtmlHead.cs
- ViewStateModeByIdAttribute.cs
- WeakHashtable.cs
- ColorConvertedBitmap.cs