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
- SecurityPermission.cs
- TextEditorLists.cs
- CapacityStreamGeometryContext.cs
- ReferenceConverter.cs
- AppModelKnownContentFactory.cs
- DbProviderFactories.cs
- AdapterUtil.cs
- ToolboxComponentsCreatingEventArgs.cs
- PlatformNotSupportedException.cs
- SettingsAttributes.cs
- SoapEnvelopeProcessingElement.cs
- DataColumnMappingCollection.cs
- XmlSchemaImporter.cs
- RoutingSection.cs
- TerminatorSinks.cs
- MsmqIntegrationBindingElement.cs
- RoleManagerModule.cs
- WmpBitmapDecoder.cs
- Maps.cs
- KnownTypesHelper.cs
- EntitySetBase.cs
- TableLayoutPanel.cs
- ConnectorEditor.cs
- FileDetails.cs
- DataGridViewButtonCell.cs
- MemberInfoSerializationHolder.cs
- XhtmlBasicPanelAdapter.cs
- Char.cs
- FontUnit.cs
- CredentialCache.cs
- mda.cs
- TaskScheduler.cs
- ObjectPropertyMapping.cs
- IPGlobalProperties.cs
- DependencyPropertyConverter.cs
- AppSettingsReader.cs
- TextEncodedRawTextWriter.cs
- adornercollection.cs
- DllNotFoundException.cs
- RichTextBox.cs
- BaseTemplateCodeDomTreeGenerator.cs
- DataGridItemCollection.cs
- SchemeSettingElementCollection.cs
- HttpCacheVary.cs
- DataGridTextBoxColumn.cs
- SpeechRecognizer.cs
- DateTimeOffset.cs
- safex509handles.cs
- ParentQuery.cs
- PrintEvent.cs
- MultipartIdentifier.cs
- TransformerInfoCollection.cs
- ValidationHelper.cs
- DataRelationCollection.cs
- ObjectToIdCache.cs
- TypeUtil.cs
- DetailsViewDeletedEventArgs.cs
- ParallelForEach.cs
- ColorContext.cs
- GenericIdentity.cs
- XmlDeclaration.cs
- ClientBuildManagerCallback.cs
- SystemPens.cs
- ConfigurationManager.cs
- DataGridViewDataErrorEventArgs.cs
- ObjectDataSourceSelectingEventArgs.cs
- CompilerCollection.cs
- BorderGapMaskConverter.cs
- ObjectDataSourceDisposingEventArgs.cs
- ToolStripRendererSwitcher.cs
- MenuAutoFormat.cs
- WorkflowClientDeliverMessageWrapper.cs
- ContainerActivationHelper.cs
- DataView.cs
- SchemaImporter.cs
- StylusPlugInCollection.cs
- PartitionResolver.cs
- embossbitmapeffect.cs
- BmpBitmapDecoder.cs
- EventLogTraceListener.cs
- RoutedEventHandlerInfo.cs
- GeometryModel3D.cs
- MediaCommands.cs
- SafeWaitHandle.cs
- AppDomainFactory.cs
- StickyNoteHelper.cs
- SID.cs
- ExecutionEngineException.cs
- TemplatedEditableDesignerRegion.cs
- SqlRowUpdatingEvent.cs
- ScrollBar.cs
- SerializationInfo.cs
- LinqTreeNodeEvaluator.cs
- FieldBuilder.cs
- TableStyle.cs
- DesignerForm.cs
- DropSource.cs
- HtmlTernaryTree.cs
- ToolStripSettings.cs
- ClientApiGenerator.cs