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
- PersonalizableAttribute.cs
- DPAPIProtectedConfigurationProvider.cs
- HtmlFormWrapper.cs
- ObjectListCommandCollection.cs
- VisualTarget.cs
- TextTrailingCharacterEllipsis.cs
- Normalizer.cs
- ExceptQueryOperator.cs
- ListParagraph.cs
- RSAPKCS1SignatureFormatter.cs
- IPPacketInformation.cs
- ConsumerConnectionPointCollection.cs
- PtsContext.cs
- SecureUICommand.cs
- SaveFileDialogDesigner.cs
- StandardOleMarshalObject.cs
- MimeBasePart.cs
- WebExceptionStatus.cs
- ControlAdapter.cs
- ZipIOLocalFileBlock.cs
- CreatingCookieEventArgs.cs
- WeakEventTable.cs
- CompilerGlobalScopeAttribute.cs
- mediapermission.cs
- ToolStripComboBox.cs
- BrowserCapabilitiesFactory35.cs
- FlowDocumentView.cs
- DynamicDataManager.cs
- DesignRelationCollection.cs
- BinaryNode.cs
- NavigateUrlConverter.cs
- AudienceUriMode.cs
- DefaultPropertyAttribute.cs
- RuntimeConfigLKG.cs
- DetailsViewDeleteEventArgs.cs
- LineBreak.cs
- OpenTypeLayout.cs
- Effect.cs
- FileDialogPermission.cs
- MobileListItemCollection.cs
- WindowAutomationPeer.cs
- HttpRawResponse.cs
- OleDbPropertySetGuid.cs
- DataGridViewColumn.cs
- TextSelectionHelper.cs
- XmlIncludeAttribute.cs
- webbrowsersite.cs
- DbReferenceCollection.cs
- CompositionTarget.cs
- FileResponseElement.cs
- DataContractJsonSerializer.cs
- OdbcCommand.cs
- TextRunCache.cs
- AbstractDataSvcMapFileLoader.cs
- MonitorWrapper.cs
- SchemaImporterExtensionElementCollection.cs
- XmlDataImplementation.cs
- SimpleApplicationHost.cs
- DataObject.cs
- AssignDesigner.xaml.cs
- SqlBuilder.cs
- AbstractDataSvcMapFileLoader.cs
- RoutedEventArgs.cs
- ClientSideProviderDescription.cs
- DBCommand.cs
- Rule.cs
- RawStylusInputCustomData.cs
- ButtonRenderer.cs
- ChameleonKey.cs
- DataGridViewCheckBoxColumn.cs
- GcSettings.cs
- SecurityDocument.cs
- DockPattern.cs
- FormViewRow.cs
- Timer.cs
- InputReportEventArgs.cs
- MethodBuilderInstantiation.cs
- CompositeScriptReference.cs
- xsdvalidator.cs
- FormViewUpdateEventArgs.cs
- TextParagraphProperties.cs
- OLEDB_Util.cs
- DesignTimeSiteMapProvider.cs
- WebPartAddingEventArgs.cs
- HealthMonitoringSection.cs
- PerformanceCounterScope.cs
- WebBrowserDocumentCompletedEventHandler.cs
- PageVisual.cs
- ParallelRangeManager.cs
- PermissionRequestEvidence.cs
- Rect3D.cs
- XmlSchemaCompilationSettings.cs
- MasterPageCodeDomTreeGenerator.cs
- BindingOperations.cs
- CommandBindingCollection.cs
- WorkflowMessageEventArgs.cs
- HashSetEqualityComparer.cs
- Registry.cs
- SqlRetyper.cs
- OpenFileDialog.cs