Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- SettingsContext.cs
- XmlRawWriter.cs
- SimpleWorkerRequest.cs
- EUCJPEncoding.cs
- TrackingConditionCollection.cs
- ParentControlDesigner.cs
- QueryCursorEventArgs.cs
- WpfKnownMemberInvoker.cs
- ServiceSecurityContext.cs
- TextMetrics.cs
- ValidationPropertyAttribute.cs
- DoubleStorage.cs
- PrePrepareMethodAttribute.cs
- DataGridCommandEventArgs.cs
- Sql8ExpressionRewriter.cs
- LoginStatusDesigner.cs
- LinqDataSourceEditData.cs
- _Semaphore.cs
- VisualStyleTypesAndProperties.cs
- Transform3DCollection.cs
- ParsedAttributeCollection.cs
- RSAPKCS1KeyExchangeFormatter.cs
- IODescriptionAttribute.cs
- CompositionAdorner.cs
- SocketElement.cs
- Container.cs
- EngineSite.cs
- ALinqExpressionVisitor.cs
- TileBrush.cs
- ExceptionHelpers.cs
- WebPartAuthorizationEventArgs.cs
- MenuItemBindingCollection.cs
- SignatureHelper.cs
- UTF7Encoding.cs
- MemoryFailPoint.cs
- SettingsPropertyCollection.cs
- TextInfo.cs
- Transform3DCollection.cs
- RequestCache.cs
- PhysicalFontFamily.cs
- WebPartsPersonalizationAuthorization.cs
- Registry.cs
- TextEditorLists.cs
- ConfigurationSectionGroupCollection.cs
- CodeObjectCreateExpression.cs
- FormViewDeletedEventArgs.cs
- DataGridViewCellFormattingEventArgs.cs
- XmlLangPropertyAttribute.cs
- RectKeyFrameCollection.cs
- ServerIdentity.cs
- FieldMetadata.cs
- _Connection.cs
- ValidationPropertyAttribute.cs
- ContentOperations.cs
- DynamicUpdateCommand.cs
- MemoryResponseElement.cs
- RelatedView.cs
- OdbcTransaction.cs
- XmlDataImplementation.cs
- EntityDataSourceStatementEditorForm.cs
- DeleteHelper.cs
- OleStrCAMarshaler.cs
- SafeFindHandle.cs
- AQNBuilder.cs
- LocalizationParserHooks.cs
- DataServiceQueryOfT.cs
- SiteOfOriginContainer.cs
- HybridCollection.cs
- ManualResetEvent.cs
- EditBehavior.cs
- GeneralTransform3D.cs
- CookieHandler.cs
- SamlSubject.cs
- IsolatedStorageFileStream.cs
- TextContainerChangeEventArgs.cs
- SoapMessage.cs
- AnimationStorage.cs
- MsmqReceiveHelper.cs
- StrokeIntersection.cs
- DataColumnMapping.cs
- HashCodeCombiner.cs
- Function.cs
- WaveHeader.cs
- SortedList.cs
- XmlWrappingReader.cs
- CapabilitiesState.cs
- CryptoApi.cs
- RoleService.cs
- ConfigurationSectionCollection.cs
- dataprotectionpermission.cs
- OdbcDataAdapter.cs
- SessionPageStateSection.cs
- CodeStatement.cs
- WebAdminConfigurationHelper.cs
- ByteStack.cs
- ProxyHwnd.cs
- BufferedReceiveManager.cs
- RootProfilePropertySettingsCollection.cs
- SourceChangedEventArgs.cs
- MimeBasePart.cs