Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Controls / AlternationConverter.cs / 1 / 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
- SByteStorage.cs
- KeyPressEvent.cs
- Win32PrintDialog.cs
- NativeWrapper.cs
- shaper.cs
- BitmapEffect.cs
- Atom10FormatterFactory.cs
- BitmapScalingModeValidation.cs
- CLSCompliantAttribute.cs
- BinaryObjectWriter.cs
- XmlSchemaAny.cs
- _emptywebproxy.cs
- SerializerWriterEventHandlers.cs
- WebInvokeAttribute.cs
- FormsAuthenticationEventArgs.cs
- BrushConverter.cs
- ParameterEditorUserControl.cs
- EncryptedXml.cs
- PaperSize.cs
- CacheEntry.cs
- DesignerView.Commands.cs
- CacheSection.cs
- SqlNotificationRequest.cs
- StreamUpdate.cs
- Base64Stream.cs
- DataTableMapping.cs
- ArrangedElement.cs
- TraceData.cs
- OrderedDictionary.cs
- PeerCollaborationPermission.cs
- TextDecoration.cs
- HtmlPhoneCallAdapter.cs
- StreamSecurityUpgradeInitiatorAsyncResult.cs
- BaseCodePageEncoding.cs
- Application.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- TextEndOfLine.cs
- DeploymentSectionCache.cs
- ListViewSortEventArgs.cs
- ScrollItemProviderWrapper.cs
- LabelExpression.cs
- SoapHeader.cs
- InkPresenter.cs
- String.cs
- AmbiguousMatchException.cs
- FlowDocumentScrollViewer.cs
- FilePrompt.cs
- XmlSchemaComplexContentRestriction.cs
- DataGridColumnReorderingEventArgs.cs
- HMACSHA256.cs
- BackoffTimeoutHelper.cs
- FirstQueryOperator.cs
- ProgressiveCrcCalculatingStream.cs
- SettingsPropertyValueCollection.cs
- Semaphore.cs
- ArrayConverter.cs
- IISUnsafeMethods.cs
- QuaternionAnimation.cs
- BooleanToVisibilityConverter.cs
- BamlResourceSerializer.cs
- ComAdminInterfaces.cs
- ModelFunction.cs
- RectangleF.cs
- DataGridViewCellStateChangedEventArgs.cs
- BypassElementCollection.cs
- Utils.cs
- SqlReferenceCollection.cs
- QilTernary.cs
- DateTimeUtil.cs
- GroupDescription.cs
- X509Chain.cs
- InternalSafeNativeMethods.cs
- TypeAccessException.cs
- DeviceFilterEditorDialog.cs
- UIntPtr.cs
- LazyTextWriterCreator.cs
- Certificate.cs
- EditorZoneBase.cs
- AllowedAudienceUriElement.cs
- RoutedCommand.cs
- Command.cs
- SafeNativeMethods.cs
- CatalogZone.cs
- BitArray.cs
- ECDiffieHellmanCng.cs
- DbProviderFactories.cs
- QueryConverter.cs
- ClientUtils.cs
- JsonDeserializer.cs
- SQLInt32Storage.cs
- Attributes.cs
- SqlPersonalizationProvider.cs
- DbConnectionClosed.cs
- xmlsaver.cs
- ItemTypeToolStripMenuItem.cs
- HttpHandlerActionCollection.cs
- BitmapCacheBrush.cs
- ResourceReferenceExpression.cs
- ClassicBorderDecorator.cs
- LayoutTable.cs