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
- HtmlValidatorAdapter.cs
- SortedSetDebugView.cs
- TraceShell.cs
- ResourcesGenerator.cs
- RangeExpression.cs
- UIElementParaClient.cs
- CustomErrorsSectionWrapper.cs
- BuildDependencySet.cs
- QilInvoke.cs
- DataStorage.cs
- SimpleMailWebEventProvider.cs
- TextBounds.cs
- ComponentCodeDomSerializer.cs
- DesignerActionUIStateChangeEventArgs.cs
- DecimalConverter.cs
- TileBrush.cs
- TimeoutException.cs
- CalendarDayButton.cs
- Focus.cs
- WindowsProgressbar.cs
- SqlEnums.cs
- MatrixCamera.cs
- WebPartZoneBaseDesigner.cs
- InputLanguageSource.cs
- StartUpEventArgs.cs
- AutomationProperties.cs
- JpegBitmapEncoder.cs
- PointCollection.cs
- SqlParameter.cs
- ShapeTypeface.cs
- ServiceNameCollection.cs
- Attributes.cs
- ControlAdapter.cs
- ThreadStartException.cs
- ScrollBar.cs
- StyleReferenceConverter.cs
- Lock.cs
- CollectionChangedEventManager.cs
- SizeKeyFrameCollection.cs
- ToolboxCategory.cs
- DbParameterCollectionHelper.cs
- ConfigViewGenerator.cs
- PeerInputChannel.cs
- SurrogateSelector.cs
- RadioButton.cs
- Relationship.cs
- GeneralTransform3DGroup.cs
- LinqDataSourceSelectEventArgs.cs
- InkCanvasAutomationPeer.cs
- PathGeometry.cs
- DeviceFilterDictionary.cs
- LinkArea.cs
- XmlSchemaSubstitutionGroup.cs
- XmlNode.cs
- LabelEditEvent.cs
- SapiInterop.cs
- MethodCallConverter.cs
- EntityDataSourceViewSchema.cs
- SettingsBase.cs
- Rfc2898DeriveBytes.cs
- OpacityConverter.cs
- OrthographicCamera.cs
- FileNotFoundException.cs
- ListViewInsertEventArgs.cs
- CultureNotFoundException.cs
- ActivationArguments.cs
- COM2FontConverter.cs
- CommonXSendMessage.cs
- WmlCalendarAdapter.cs
- _AutoWebProxyScriptEngine.cs
- DataGridViewComboBoxEditingControl.cs
- OleDbDataReader.cs
- ArcSegment.cs
- ReaderWriterLock.cs
- HttpListenerResponse.cs
- EntitySqlQueryCacheEntry.cs
- MatchingStyle.cs
- ViewGenResults.cs
- PeerApplication.cs
- HtmlCalendarAdapter.cs
- SoundPlayer.cs
- TimeManager.cs
- ElementHost.cs
- PresentationSource.cs
- CommonObjectSecurity.cs
- DataGridItem.cs
- BaseAutoFormat.cs
- lengthconverter.cs
- _NTAuthentication.cs
- EventHandlingScope.cs
- PanelStyle.cs
- PrintingPermission.cs
- BamlCollectionHolder.cs
- DataSourceConverter.cs
- SafeReversePInvokeHandle.cs
- AlphabeticalEnumConverter.cs
- ToolboxItemLoader.cs
- PromptBuilder.cs
- EntityDesignerUtils.cs
- Expander.cs