Aracılığıyla paylaş


AlternationConverter.Values Özellik

Tanım

Yöntemine bir tamsayı geçirildiğinde Convert(Object, Type, Object, CultureInfo) döndürdüğü AlternationConverter nesnelerin listesini alır.

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

Özellik Değeri

IList

yöntemine bir tamsayı geçirildiğinde Convert(Object, Type, Object, CultureInfo) döndürdüğü AlternationConverter nesnelerin listesi.

Örnekler

Aşağıdaki örnek bir ListBox oluşturur ve öğelerini ve öğelerini değiştirmek Background FontStyle için iki AlternationConverter nesne kullanır.

<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>

Açıklamalar

bir özelliği değişen değerlere bağlamak için kullandığınızda AlternationConverter , Values özelliği özelliğine atanan nesneleri içerir. Örneğin, içindeki ListBox öğelerin alternatif mavi ve açık mavi arka planlara sahip olmasını istiyorsanız, öğesine mavi SolidColorBrush ve açık mavi SolidColorBrush Valueseklersiniz.

Şunlara uygulanır