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

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 öğelerinin ve FontStyle öğelerini değiştirmek Background 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 komutunu 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 Valuesmavi SolidColorBrush ve açık mavi SolidColorBrush eklersiniz.

Şunlara uygulanır