AlternationConverter.Values プロパティ

定義

整数が AlternationConverter メソッドに渡されたときに Convert(Object, Type, Object, CultureInfo) が返すオブジェクトのリストを取得します。

public:
 property System::Collections::IList ^ Values { System::Collections::IList ^ get(); };
public System.Collections.IList Values { get; }
member this.Values : System.Collections.IList
Public ReadOnly Property Values As IList

プロパティ値

整数が AlternationConverter メソッドに渡されたときに Convert(Object, Type, Object, CultureInfo) が返すオブジェクトのリスト。

次の例では、 をListBox作成し、2 つのAlternationConverterオブジェクトを使用して 項目の と FontStyleBackground交互に使用します。

<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 使用してプロパティを交互の値にバインドする場合、 Values プロパティには プロパティに割り当てられているオブジェクトが含まれます。 たとえば、 の項目に ListBox 青と水色の背景を交互に設定する場合は、 に青 SolidColorBrush と水色 SolidColorBrush を追加します Values

適用対象