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
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기