我有一个ItemsControl。对于ItemsControl中的最后一项,我想隐藏包含逗号的TextBox。是否有一种使用XAML来实现这个目标的方法?
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Visibility="{Binding Value, Converter={StaticResource NotEmpty}}">
<TextBlock Text="{Binding QuestionName}" />
<TextBlock Text=" " />
<TextBlock Text="{Binding Answer}"/>
<TextBlock Text=", " />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
TextBlock
和一个ValueConverter
来执行String.Join(...)
而不是使用ItemsControl。 - herzmeister