Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- HotCommands.cs
- ListItemsPage.cs
- OverlappedAsyncResult.cs
- XmlSchemaException.cs
- _Events.cs
- ButtonPopupAdapter.cs
- EntityProviderServices.cs
- ServicePointManagerElement.cs
- TileBrush.cs
- LineInfo.cs
- BinaryParser.cs
- Processor.cs
- BulletChrome.cs
- ConsoleCancelEventArgs.cs
- IsolatedStorage.cs
- ColumnBinding.cs
- ListViewDataItem.cs
- RegisteredScript.cs
- ObjectHelper.cs
- TaiwanLunisolarCalendar.cs
- TableLayoutSettingsTypeConverter.cs
- LocatorManager.cs
- ProcessModelSection.cs
- NullableConverter.cs
- TaskFormBase.cs
- PopOutPanel.cs
- XsltFunctions.cs
- ListViewDataItem.cs
- ItemsPresenter.cs
- updatecommandorderer.cs
- WebServiceAttribute.cs
- ServiceModelSecurityTokenTypes.cs
- ActivationArguments.cs
- WizardSideBarListControlItemEventArgs.cs
- ParentQuery.cs
- DeferredReference.cs
- EncoderNLS.cs
- Pen.cs
- AssemblyBuilderData.cs
- OracleString.cs
- ThemeableAttribute.cs
- TableLayoutSettingsTypeConverter.cs
- Label.cs
- PathTooLongException.cs
- DrawingContextWalker.cs
- UIElement.cs
- TypeTypeConverter.cs
- UriScheme.cs
- PropertiesTab.cs
- RelOps.cs
- Compiler.cs
- GifBitmapDecoder.cs
- InboundActivityHelper.cs
- SmiContext.cs
- DocumentPageView.cs
- ConnectivityStatus.cs
- _DigestClient.cs
- Clipboard.cs
- ReliabilityContractAttribute.cs
- StringOutput.cs
- SHA1.cs
- ApplicationSecurityManager.cs
- QueryInterceptorAttribute.cs
- DataGridViewCheckBoxColumn.cs
- SharedDp.cs
- UnsafeNativeMethodsMilCoreApi.cs
- AuthenticatingEventArgs.cs
- SmuggledIUnknown.cs
- InternalConfigSettingsFactory.cs
- Base64Encoding.cs
- TdsParserStaticMethods.cs
- Knowncolors.cs
- AppDomain.cs
- WebWorkflowRole.cs
- RepeatButton.cs
- NameNode.cs
- ContextMenuAutomationPeer.cs
- CollectionsUtil.cs
- TypeConvertions.cs
- TrackingLocation.cs
- PageSetupDialog.cs
- GridViewDeleteEventArgs.cs
- ExpandoObject.cs
- TreeBuilderXamlTranslator.cs
- PriorityBinding.cs
- GcSettings.cs
- HtmlHistory.cs
- WebServiceFault.cs
- MailMessage.cs
- GeneralTransform.cs
- AccessKeyManager.cs
- RelationshipNavigation.cs
- XmlToDatasetMap.cs
- SQLDateTimeStorage.cs
- ContourSegment.cs
- AudioLevelUpdatedEventArgs.cs
- ReachPageContentSerializer.cs
- GZipStream.cs
- TextPattern.cs
- XPathException.cs