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
- MessageQueueCriteria.cs
- PeerPresenceInfo.cs
- DataViewSettingCollection.cs
- BindingBase.cs
- WindowsGraphicsWrapper.cs
- EnumerableRowCollectionExtensions.cs
- CodeAttributeDeclaration.cs
- MeasureData.cs
- CqlLexerHelpers.cs
- HtmlInputSubmit.cs
- WebPartManagerInternals.cs
- Win32PrintDialog.cs
- WebPartsPersonalization.cs
- OdbcCommand.cs
- StackBuilderSink.cs
- UriTemplateDispatchFormatter.cs
- AppDomain.cs
- StorageFunctionMapping.cs
- SupportsEventValidationAttribute.cs
- Fault.cs
- TextProperties.cs
- OdbcConnectionFactory.cs
- EditorPartCollection.cs
- PropertyGroupDescription.cs
- CorrelationExtension.cs
- SymmetricAlgorithm.cs
- CollectionView.cs
- ParameterElement.cs
- ListBindableAttribute.cs
- NamespaceMapping.cs
- MouseGestureValueSerializer.cs
- _Win32.cs
- _AcceptOverlappedAsyncResult.cs
- SecurityRuntime.cs
- TextCollapsingProperties.cs
- Helpers.cs
- EnumerableCollectionView.cs
- FontConverter.cs
- CodeExpressionCollection.cs
- DocumentPageHost.cs
- XmlWellformedWriter.cs
- ModelFunction.cs
- ScriptControl.cs
- InputProcessorProfilesLoader.cs
- SafeNativeMethods.cs
- SecondaryIndexDefinition.cs
- ComponentDesigner.cs
- SafeFileMapViewHandle.cs
- DataServiceQueryProvider.cs
- IPPacketInformation.cs
- InplaceBitmapMetadataWriter.cs
- DateTimeParse.cs
- CompressStream.cs
- ReadOnlyDataSourceView.cs
- FilterQuery.cs
- PriorityChain.cs
- MtomMessageEncodingElement.cs
- PropertyState.cs
- ObjectDataSourceView.cs
- ActivityBuilderHelper.cs
- SmtpCommands.cs
- Crypto.cs
- InternalConfigHost.cs
- ProfileSettingsCollection.cs
- HtmlWindow.cs
- FixedDocumentPaginator.cs
- ErrorWrapper.cs
- LongTypeConverter.cs
- DataGridViewComponentPropertyGridSite.cs
- ProfileInfo.cs
- ScriptRegistrationManager.cs
- DescendantBaseQuery.cs
- ProfileSettings.cs
- FormatSettings.cs
- CapabilitiesRule.cs
- ConfigurationPropertyAttribute.cs
- EDesignUtil.cs
- DataGridBoolColumn.cs
- PasswordTextContainer.cs
- DurableServiceAttribute.cs
- FormsAuthentication.cs
- ToolStripItemClickedEventArgs.cs
- FileDialog_Vista.cs
- HttpCookiesSection.cs
- QuaternionAnimation.cs
- OrderByQueryOptionExpression.cs
- _NTAuthentication.cs
- BaseCollection.cs
- WebProxyScriptElement.cs
- TransportSecurityHelpers.cs
- XmlILTrace.cs
- RolePrincipal.cs
- NumberFormatter.cs
- TextFormatterContext.cs
- ConfigurationSectionGroupCollection.cs
- PrintPreviewGraphics.cs
- HMAC.cs
- EventEntry.cs
- X509IssuerSerialKeyIdentifierClause.cs
- ContractTypeNameCollection.cs