【发布时间】:2017-03-05 21:39:39
【问题描述】:
我有 ItemsControl,每个项目都有可绑定的 itemsource 和自定义日期模板。项目由行分隔。但是最后一项也有分隔符,这就是我的问题,如何不为最后一项呈现线。我找到了这个解决方案,但它在 WPF 中工作:
How can a separator be added between items in an ItemsControl
编辑: 这是我的模板:
<ItemsControl Grid.Row="1" ItemsSource="{x:Bind ViewModel.AvailableStatuses}" x:Name="Statuses">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" Padding="60,0,60,12"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:InvokeCommandAction Command="{Binding ElementName=ContentGrid, Path=DataContext.ChangeStatusCommand}" CommandParameter="{Binding}"/>
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
<Rectangle StrokeThickness="0.4" Height="0.4" x:Name="Separator"
VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Stroke="#D1D3D4" />
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Stretch">
<Image Source="{Binding Converter={StaticResource SelectContactStatusConverter}}" Margin="0,8,12,8"/>
<TextBlock Text="{Binding Converter={StaticResource EnumContactStatusToTextConverter}}" FontSize="20" VerticalAlignment="Center" Foreground="Black"/>
</StackPanel>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
【问题讨论】:
标签: xaml windows-runtime uwp winrt-xaml uwp-xaml