AlternationConverter.Values Właściwość

Definicja

Pobiera listę obiektów zwracanych AlternationConverter po przekazaniu liczby całkowitej Convert(Object, Type, Object, CultureInfo) do metody .

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

Wartość właściwości

IList

Lista obiektów zwracanych AlternationConverter po przekazaniu liczby całkowitej Convert(Object, Type, Object, CultureInfo) do metody .

Przykłady

Poniższy przykład tworzy obiekt ListBox i używa dwóch AlternationConverter obiektów do alternatywnego elementu Background i FontStyle .

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

Uwagi

Gdy używasz AlternationConverter elementu , aby powiązać właściwość z wartościami zmiennymi, Values właściwość zawiera obiekty przypisane do właściwości. Jeśli na przykład chcesz, aby elementy w obiekcie ListBox miały na przemian niebieskie i jasnoniebieskie tła, należy dodać niebieski SolidColorBrush i jasnoniebieski SolidColorBrush do Valueselementu .

Dotyczy