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
- ConsoleCancelEventArgs.cs
- AutomationProperty.cs
- TabletCollection.cs
- RelationshipConverter.cs
- DatatypeImplementation.cs
- TrimSurroundingWhitespaceAttribute.cs
- BufferModeSettings.cs
- VectorCollectionConverter.cs
- Range.cs
- ParseChildrenAsPropertiesAttribute.cs
- Schema.cs
- LoadedEvent.cs
- DelayedRegex.cs
- HotSpot.cs
- SqlPersonalizationProvider.cs
- ResolveResponseInfo.cs
- altserialization.cs
- IPAddress.cs
- WebSysDefaultValueAttribute.cs
- TagMapInfo.cs
- ReservationCollection.cs
- COM2PictureConverter.cs
- ObjectStateManager.cs
- XPathArrayIterator.cs
- DbSourceCommand.cs
- WebCategoryAttribute.cs
- ParameterCollection.cs
- XmlILStorageConverter.cs
- Recipient.cs
- BufferModesCollection.cs
- Helpers.cs
- NavigationService.cs
- EncoderReplacementFallback.cs
- SQLByteStorage.cs
- WorkflowOperationAsyncResult.cs
- DiscoveryEndpointElement.cs
- TerminateSequenceResponse.cs
- MessageQueueKey.cs
- ReservationCollection.cs
- PropertyNames.cs
- RectangleHotSpot.cs
- RecordManager.cs
- RightsManagementResourceHelper.cs
- Line.cs
- DateTimeConverter2.cs
- PasswordBox.cs
- RulePatternOps.cs
- WebPartCatalogCloseVerb.cs
- SystemColorTracker.cs
- SQLDecimalStorage.cs
- AmbientLight.cs
- OrthographicCamera.cs
- UnsafeNativeMethods.cs
- DefaultAssemblyResolver.cs
- SqlServices.cs
- _AutoWebProxyScriptEngine.cs
- _NetRes.cs
- DynamicILGenerator.cs
- ProtocolElement.cs
- DataSourceSelectArguments.cs
- SerialStream.cs
- SolidColorBrush.cs
- KeyboardInputProviderAcquireFocusEventArgs.cs
- HandlerBase.cs
- SqlDeflator.cs
- PlaceHolder.cs
- BadImageFormatException.cs
- TextChange.cs
- HostAdapter.cs
- DrawingImage.cs
- SecurityIdentifierConverter.cs
- BuildManagerHost.cs
- Menu.cs
- SapiRecognizer.cs
- MimeMapping.cs
- SequenceDesigner.cs
- DataGridItemEventArgs.cs
- CounterCreationDataCollection.cs
- BinaryQueryOperator.cs
- ReservationCollection.cs
- MethodCallTranslator.cs
- EdmError.cs
- TextModifier.cs
- TextBoxRenderer.cs
- ObjectDesignerDataSourceView.cs
- WhitespaceRule.cs
- ProfessionalColors.cs
- RotateTransform.cs
- EventLogPermissionEntryCollection.cs
- Helpers.cs
- FrameworkElementAutomationPeer.cs
- DetailsViewUpdateEventArgs.cs
- TemplatedWizardStep.cs
- xmlformatgeneratorstatics.cs
- ADConnectionHelper.cs
- CompositeControl.cs
- NewItemsContextMenuStrip.cs
- TargetParameterCountException.cs
- CodeCompiler.cs
- ContentPropertyAttribute.cs