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
- IntranetCredentialPolicy.cs
- ProcessInputEventArgs.cs
- ISAPIWorkerRequest.cs
- TraceContextEventArgs.cs
- ParallelRangeManager.cs
- RuleInfoComparer.cs
- MaterialGroup.cs
- RadioButtonDesigner.cs
- __TransparentProxy.cs
- XmlILConstructAnalyzer.cs
- ConfigurationConverterBase.cs
- Helpers.cs
- FrameworkElementAutomationPeer.cs
- NumericUpDownAccelerationCollection.cs
- InfiniteTimeSpanConverter.cs
- SqlFunctions.cs
- ListDictionaryInternal.cs
- References.cs
- PipeSecurity.cs
- FixedSOMTextRun.cs
- ConfigurationPropertyAttribute.cs
- MachineKeySection.cs
- SqlUnionizer.cs
- RoleManagerEventArgs.cs
- NativeMethods.cs
- CommonDialog.cs
- Page.cs
- DataDocumentXPathNavigator.cs
- Event.cs
- ParameterCollection.cs
- WrappedOptions.cs
- RelatedView.cs
- TextCompositionEventArgs.cs
- HostingEnvironment.cs
- RotateTransform.cs
- XmlUTF8TextReader.cs
- DataGridViewDataConnection.cs
- Configuration.cs
- RSAOAEPKeyExchangeDeformatter.cs
- SignedXml.cs
- Size3DValueSerializer.cs
- MailAddressCollection.cs
- WebPartConnectionsConfigureVerb.cs
- DemultiplexingClientMessageFormatter.cs
- ProcessHostMapPath.cs
- HandleRef.cs
- PathFigureCollectionConverter.cs
- xml.cs
- ObjectStateFormatter.cs
- ConnectionProviderAttribute.cs
- DataGridCellAutomationPeer.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- TokenBasedSetEnumerator.cs
- SqlNamer.cs
- shaperfactory.cs
- TextTrailingWordEllipsis.cs
- DbProviderConfigurationHandler.cs
- WebPartConnectionsCloseVerb.cs
- SQLInt32.cs
- ColumnMap.cs
- ButtonBaseAdapter.cs
- RequestUriProcessor.cs
- AttributeEmitter.cs
- RecipientInfo.cs
- RegexMatch.cs
- TreeViewCancelEvent.cs
- CompositeKey.cs
- HwndSourceKeyboardInputSite.cs
- DbParameterCollection.cs
- SharedStatics.cs
- TextEditorDragDrop.cs
- TraceHwndHost.cs
- TemplateNameScope.cs
- XslTransform.cs
- ExpandSegment.cs
- TextProviderWrapper.cs
- IPipelineRuntime.cs
- AttributedMetaModel.cs
- ParserStack.cs
- WebPartVerbsEventArgs.cs
- DataObjectMethodAttribute.cs
- PublishLicense.cs
- WebBaseEventKeyComparer.cs
- DiscoveryClientProtocol.cs
- TemplateField.cs
- ADRoleFactory.cs
- ObjectDataSourceWizardForm.cs
- KeyValueSerializer.cs
- TemplateControlBuildProvider.cs
- ImagingCache.cs
- AutoCompleteStringCollection.cs
- DataTableNewRowEvent.cs
- XmlAnyElementAttributes.cs
- AnnouncementInnerClientCD1.cs
- NavigationPropertySingletonExpression.cs
- GeneralEndpointIdentity.cs
- RelationshipNavigation.cs
- ApplicationActivator.cs
- ModelItemExtensions.cs
- TransactionState.cs