阅读背景:

ListBox项模板中绑定ListBoxItem属性的方法

来源:互联网 
<ListBox>
	<ListBox.ItemTemplate>
		<DataTemplate>
			<Grid Width="225"  Height="126" FocusVisualStyle="{x:Null}">
				<TextBlock 
					x:Name="sortIndex"
					FontFamily="微软雅黑" FontSize="18" Foreground="Black"
					HorizontalAlignment="Left" VerticalAlignment="Top"
					Text="test"/>
			</Grid>
			<DataTemplate.Triggers>
				<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=1,AncestorType={x:Type ListBoxItem}}}" Value="True">
					<Setter Property="Foreground" TargetName="sortIndex" Value="White"/>
				</DataTrigger>
			</DataTemplate.Triggers>
		</DataTemplate>
	</ListBox.ItemTemplate>
</ListBox>
<ListBox>
	<ListBox.ItemTemplate>
		<D



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: