【发布时间】:2016-08-21 14:44:49
【问题描述】:
我的问题是另一个帖子的后续问题:What are the different triggers in WPF?
我想设置一个触发器,如果该项目是列表视图中的第一个则触发(这样我可以添加额外的文本)。我应该使用哪种类型的触发器?
这是我的代码:
<ListView Grid.Row="1" Grid.Column="2" Name="contactList" Margin="0,0,0,0">
<ListView.ItemTemplate>
<DataTemplate>
<WrapPanel>
<TextBlock Text="{Binding Name}" />
<TextBlock>
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<Trigger <!-- what do I have to put here so it triggers when the item is the first one in the list? -->>
<Setter Property="Text" Value=" - this is the first item in the list!!"/>
<Setter Property="Foreground" Value="#7f8c8d"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</WrapPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
【问题讨论】: