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
- Style.cs
- PtsCache.cs
- WindowManager.cs
- NumberSubstitution.cs
- GlobalizationAssembly.cs
- Message.cs
- GeneralTransform2DTo3DTo2D.cs
- ProcessModuleCollection.cs
- StatusBarItemAutomationPeer.cs
- XPathNodeInfoAtom.cs
- FocusChangedEventArgs.cs
- Point4D.cs
- BitmapEffectInputData.cs
- AnchorEditor.cs
- DataGridViewComboBoxEditingControl.cs
- FilterableAttribute.cs
- DependencyPropertyAttribute.cs
- Context.cs
- EntityChangedParams.cs
- ResourceReader.cs
- Frame.cs
- StatusBar.cs
- Tile.cs
- oledbconnectionstring.cs
- WorkflowServiceHostFactory.cs
- DragDrop.cs
- ConnectionInterfaceCollection.cs
- StreamGeometry.cs
- ScrollEventArgs.cs
- GridViewUpdatedEventArgs.cs
- FileDialogCustomPlace.cs
- ColumnBinding.cs
- DataGridColumnDropSeparator.cs
- SafeHandle.cs
- TdsParser.cs
- AttributeCollection.cs
- TextCompositionEventArgs.cs
- NavigationWindowAutomationPeer.cs
- ExceptionHandlersDesigner.cs
- StoreAnnotationsMap.cs
- ZipFileInfo.cs
- ToolboxItemFilterAttribute.cs
- XmlWriterSettings.cs
- Cell.cs
- ErrorHandler.cs
- safemediahandle.cs
- FixedSOMPageElement.cs
- MenuCommand.cs
- GlobalItem.cs
- StateBag.cs
- ItemChangedEventArgs.cs
- SchemaTypeEmitter.cs
- TaskCanceledException.cs
- StateMachineSubscription.cs
- TrustManager.cs
- TraversalRequest.cs
- InvalidCommandTreeException.cs
- PeerObject.cs
- XmlSchemaValidationException.cs
- ClientUtils.cs
- WebPartZoneDesigner.cs
- InputBuffer.cs
- ListViewGroupConverter.cs
- EventLogPermissionAttribute.cs
- TabPanel.cs
- XmlILAnnotation.cs
- _RequestCacheProtocol.cs
- ConnectionStringsExpressionEditor.cs
- xmlNames.cs
- XmlElementElementCollection.cs
- Size.cs
- StylusEditingBehavior.cs
- DataGridLinkButton.cs
- ExpressionEditorAttribute.cs
- DisplayInformation.cs
- CfgParser.cs
- DetailsViewRowCollection.cs
- WebSysDisplayNameAttribute.cs
- TextRangeSerialization.cs
- XPathParser.cs
- UserControlAutomationPeer.cs
- SystemInfo.cs
- WebServicesSection.cs
- DataGridCommandEventArgs.cs
- DataControlPagerLinkButton.cs
- RegexCaptureCollection.cs
- MenuRendererClassic.cs
- SqlInternalConnection.cs
- ServiceHandle.cs
- EventSource.cs
- SelectionEditingBehavior.cs
- MediaCommands.cs
- Parser.cs
- ClientRoleProvider.cs
- MetafileHeader.cs
- regiisutil.cs
- BitVector32.cs
- PlatformCulture.cs
- TextBlockAutomationPeer.cs
- NativeWindow.cs