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 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈