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
- CompositionTarget.cs
- NamespaceDecl.cs
- TextFragmentEngine.cs
- SchemaImporter.cs
- ComponentManagerBroker.cs
- ISessionStateStore.cs
- XmlSchemaDocumentation.cs
- DataGridCommandEventArgs.cs
- TemplatedWizardStep.cs
- FrugalMap.cs
- UIElementCollection.cs
- HttpCapabilitiesEvaluator.cs
- IntSumAggregationOperator.cs
- PrintDialogDesigner.cs
- RoutedEventArgs.cs
- metadatamappinghashervisitor.cs
- StructuredTypeEmitter.cs
- SortedList.cs
- RelationshipWrapper.cs
- InputProcessorProfiles.cs
- PermissionToken.cs
- SystemFonts.cs
- BaseProcessProtocolHandler.cs
- ConfigUtil.cs
- WindowsListView.cs
- ReflectTypeDescriptionProvider.cs
- NamespaceQuery.cs
- DataObjectEventArgs.cs
- Buffer.cs
- CompilerWrapper.cs
- BindingWorker.cs
- CodeRemoveEventStatement.cs
- ProcessModelSection.cs
- CatalogZoneBase.cs
- SQLBoolean.cs
- ArrangedElement.cs
- ComponentEvent.cs
- AmbientLight.cs
- ThousandthOfEmRealPoints.cs
- SapiInterop.cs
- arabicshape.cs
- AutoCompleteStringCollection.cs
- DesignerInterfaces.cs
- EFTableProvider.cs
- HtmlPageAdapter.cs
- RoleManagerModule.cs
- ExternalException.cs
- Soap.cs
- ScriptDescriptor.cs
- XPathSingletonIterator.cs
- Brush.cs
- LoginUtil.cs
- LinkArea.cs
- dbenumerator.cs
- ExecutionEngineException.cs
- TdsParserHelperClasses.cs
- Point3D.cs
- PathFigureCollectionValueSerializer.cs
- CodePageEncoding.cs
- storagemappingitemcollection.viewdictionary.cs
- RawStylusActions.cs
- MatrixTransform3D.cs
- OperationResponse.cs
- CustomAttributeSerializer.cs
- SecurityCapabilities.cs
- DataSetMappper.cs
- Permission.cs
- SchemaNotation.cs
- SupportsEventValidationAttribute.cs
- XpsFilter.cs
- UnmanagedMemoryStream.cs
- TargetConverter.cs
- CacheOutputQuery.cs
- PseudoWebRequest.cs
- SchemaType.cs
- CurrencyWrapper.cs
- EventRoute.cs
- Brush.cs
- UnconditionalPolicy.cs
- ChannelReliableSession.cs
- Exceptions.cs
- RadioButton.cs
- ScriptControlManager.cs
- AttributeData.cs
- PackageRelationshipSelector.cs
- PositiveTimeSpanValidatorAttribute.cs
- HttpResponseInternalWrapper.cs
- DataGridViewButtonCell.cs
- UserPreferenceChangingEventArgs.cs
- StreamMarshaler.cs
- ScriptingSectionGroup.cs
- CommandID.cs
- Util.cs
- FlowLayout.cs
- NameValueCollection.cs
- StdValidatorsAndConverters.cs
- WindowsTreeView.cs
- ProtectedProviderSettings.cs
- ToolStripDesignerAvailabilityAttribute.cs
- FormsAuthenticationUser.cs