Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- XmlMembersMapping.cs
- QueryCacheKey.cs
- RelationshipManager.cs
- EntityDataSourceEntitySetNameItem.cs
- LayoutEngine.cs
- DataGridCommandEventArgs.cs
- ProxyFragment.cs
- IDispatchConstantAttribute.cs
- MethodBuilder.cs
- SymmetricAlgorithm.cs
- userdatakeys.cs
- MobileTemplatedControlDesigner.cs
- PowerStatus.cs
- StaticFileHandler.cs
- SizeValueSerializer.cs
- SymbolMethod.cs
- ResponseStream.cs
- DataGridBoolColumn.cs
- StrokeNodeData.cs
- SafeCoTaskMem.cs
- ClickablePoint.cs
- XmlCodeExporter.cs
- EncryptedType.cs
- ObjectDataSourceSelectingEventArgs.cs
- TreeNodeEventArgs.cs
- MeshGeometry3D.cs
- ComEventsSink.cs
- SubMenuStyle.cs
- MembershipPasswordException.cs
- Odbc32.cs
- FormsAuthenticationModule.cs
- TypeToken.cs
- PropertyIDSet.cs
- ConnectionStringsExpressionBuilder.cs
- HttpResponseInternalWrapper.cs
- PagerSettings.cs
- UpdateCommand.cs
- NativeMethods.cs
- CodeGenerator.cs
- SettingsBase.cs
- NativeCompoundFileAPIs.cs
- ImageList.cs
- ComponentManagerBroker.cs
- _SingleItemRequestCache.cs
- RadioButton.cs
- ElementProxy.cs
- HttpProfileGroupBase.cs
- UdpDuplexChannel.cs
- FactoryId.cs
- ParameterCollection.cs
- PropertyGroupDescription.cs
- ArrayConverter.cs
- HScrollProperties.cs
- RootBuilder.cs
- VBCodeProvider.cs
- CFStream.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- XmlObjectSerializer.cs
- BmpBitmapDecoder.cs
- SimpleHandlerBuildProvider.cs
- DurableInstancingOptions.cs
- ThreadNeutralSemaphore.cs
- NumberFunctions.cs
- DocumentDesigner.cs
- VisualState.cs
- GeometryHitTestResult.cs
- Descriptor.cs
- DefaultHttpHandler.cs
- SystemInformation.cs
- MemberMaps.cs
- X500Name.cs
- C14NUtil.cs
- _TimerThread.cs
- Form.cs
- WaitHandleCannotBeOpenedException.cs
- DecimalStorage.cs
- PropertyRecord.cs
- DeflateEmulationStream.cs
- DispatcherHookEventArgs.cs
- DbConnectionPoolCounters.cs
- InkCanvasAutomationPeer.cs
- SspiNegotiationTokenProvider.cs
- DoubleSumAggregationOperator.cs
- DataKey.cs
- XmlDocumentType.cs
- CommandCollectionEditor.cs
- SQLSingleStorage.cs
- SqlPersonalizationProvider.cs
- AttachedPropertiesService.cs
- CheckBoxBaseAdapter.cs
- Effect.cs
- PDBReader.cs
- CompiledRegexRunnerFactory.cs
- UInt16.cs
- DataRecordInfo.cs
- Utils.cs
- FloaterParaClient.cs
- SqlBooleanizer.cs
- XmlSchemaComplexContentExtension.cs
- HttpsChannelFactory.cs