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
- InternalConfigEventArgs.cs
- NativeRightsManagementAPIsStructures.cs
- DeclarativeCatalogPart.cs
- MenuRendererClassic.cs
- SingleAnimationBase.cs
- WorkItem.cs
- StyleTypedPropertyAttribute.cs
- Floater.cs
- CalendarModeChangedEventArgs.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- ModelItemCollection.cs
- Odbc32.cs
- ArrayHelper.cs
- SoundPlayerAction.cs
- SQLMembershipProvider.cs
- FormViewInsertEventArgs.cs
- ReadOnlyTernaryTree.cs
- WindowsStatic.cs
- BaseDataList.cs
- XmlReaderDelegator.cs
- DataGridViewCellValidatingEventArgs.cs
- BoolExpr.cs
- ApplicationSecurityManager.cs
- VersionPair.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- SmiRequestExecutor.cs
- ApplicationInfo.cs
- DataChangedEventManager.cs
- UnsafeNativeMethodsMilCoreApi.cs
- StopStoryboard.cs
- HelpInfo.cs
- ReplacementText.cs
- DependentList.cs
- NavigationWindowAutomationPeer.cs
- FileCodeGroup.cs
- versioninfo.cs
- ClassHandlersStore.cs
- cryptoapiTransform.cs
- TriggerBase.cs
- ProtocolsConfiguration.cs
- DataControlReferenceCollection.cs
- XsdDataContractExporter.cs
- MenuAutomationPeer.cs
- ToolStripArrowRenderEventArgs.cs
- MbpInfo.cs
- ConversionContext.cs
- SharedUtils.cs
- RemoteWebConfigurationHost.cs
- _AutoWebProxyScriptEngine.cs
- TypeNameConverter.cs
- GridViewDeletedEventArgs.cs
- M3DUtil.cs
- StoreItemCollection.cs
- Visual3D.cs
- DataGridViewCellStateChangedEventArgs.cs
- SectionUpdates.cs
- OutputCache.cs
- ResourceAssociationSet.cs
- ConfigUtil.cs
- ReflectTypeDescriptionProvider.cs
- ConstrainedGroup.cs
- PolicyFactory.cs
- NameValueConfigurationElement.cs
- DataBinder.cs
- TablePattern.cs
- ShaderEffect.cs
- ListBoxAutomationPeer.cs
- WebColorConverter.cs
- ColorDialog.cs
- XmlSerializationGeneratedCode.cs
- LinkButton.cs
- ActiveXSite.cs
- UserControlAutomationPeer.cs
- InfocardExtendedInformationCollection.cs
- ColorContext.cs
- VisualBasicExpressionConverter.cs
- TextWriter.cs
- DynamicMetaObject.cs
- XmlSchemaAttributeGroupRef.cs
- MonthChangedEventArgs.cs
- SimpleWorkerRequest.cs
- SrgsDocumentParser.cs
- CodeNamespace.cs
- WinFormsSpinner.cs
- WindowShowOrOpenTracker.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- SimpleWebHandlerParser.cs
- Compiler.cs
- BindableAttribute.cs
- ClassHandlersStore.cs
- ChannelCredentials.cs
- FutureFactory.cs
- LayoutExceptionEventArgs.cs
- HTTPRemotingHandler.cs
- UpdatePanelControlTrigger.cs
- SchemaNotation.cs
- Pair.cs
- Polyline.cs
- UnsettableComboBox.cs
- XmlILOptimizerVisitor.cs