AlternationConverter.Values Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a list of objects that the AlternationConverter returns when an integer is passed to the Convert(Object, Type, Object, CultureInfo) method.
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
Property Value
A list of objects that the AlternationConverter returns when an integer is passed to the Convert(Object, Type, Object, CultureInfo) method.
Examples
The following example creates a ListBox and uses two AlternationConverter objects to alternate the Background and FontStyle of the items.
<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>
Remarks
When you use the AlternationConverter to bind a property to alternating values, the Values property contains the objects that are assigned to the property. For example, if you want items in a ListBox to have alternating blue and light blue backgrounds, you add a blue SolidColorBrush and a light blue SolidColorBrush to Values.
Applies to
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應