AlternationConverter 클래스

정의

정수를 개체 목록에 대한 인덱스로 적용하여 정수와 개체를 서로 변환합니다.

public ref class AlternationConverter : System::Windows::Data::IValueConverter
[System.Windows.Markup.ContentProperty("Values")]
public class AlternationConverter : System.Windows.Data.IValueConverter
[<System.Windows.Markup.ContentProperty("Values")>]
type AlternationConverter = class
    interface IValueConverter
Public Class AlternationConverter
Implements IValueConverter
상속
AlternationConverter
특성
구현

예제

다음 예제에서는 ListBox 2를 사용 하 여 AlternationConverter 대체 하는 개체를 BackgroundFontStyle 항목의 합니다.

<Grid>
  <Grid.Resources>
    <AlternationConverter x:Key="BackgroundConverter">
      <SolidColorBrush>Blue</SolidColorBrush>
      <SolidColorBrush>LightBlue</SolidColorBrush>
    </AlternationConverter>

    <AlternationConverter x:Key="FontStyleConverter">
      <FontStyle >Italic</FontStyle>
      <FontStyle >Normal</FontStyle>
    </AlternationConverter>

    <Style x:Key="alternatingWithBinding" TargetType="{x:Type ListBoxItem}">
      <Setter Property="Background" 
              Value="{Binding RelativeSource={RelativeSource Self},
                     Path=(ItemsControl.AlternationIndex),
                     Converter={StaticResource BackgroundConverter}}"/>

      <Setter Property="FontStyle" 
              Value="{Binding RelativeSource={RelativeSource Self},
                     Path=(ItemsControl.AlternationIndex),
                     Converter={StaticResource FontStyleConverter}}"/>
    </Style>

  </Grid.Resources>

  <ListBox AlternationCount="2" ItemsSource="{StaticResource data}"
           ItemContainerStyle="{StaticResource alternatingWithBinding}"/>
</Grid>

설명

사용할 수는 AlternationConverter 바인딩할 속성 값을 대체 합니다. 예를 들어 원하는 항목을 ListBox 교대로 반복 되는 파란색 및 연한 파란색 배경을 하려면 다음을 수행 하면:

생성자

AlternationConverter()

AlternationConverter 클래스의 새 인스턴스를 초기화합니다.

속성

Values

AlternationConverter 메서드에 정수를 전달하면 Convert(Object, Type, Object, CultureInfo)가 반환하는 개체 목록을 가져옵니다.

메서드

Convert(Object, Type, Object, CultureInfo)

정수를 Values 목록의 개체로 변환합니다.

ConvertBack(Object, Type, Object, CultureInfo)

Values 목록의 개체를 정수로 변환합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상