【发布时间】:2015-03-07 12:52:27
【问题描述】:
我有一个RadDataBoundListBox(来自 Telerik),它代表列表中的项目。每个项目都由底线x:Name="ItemSeparatorBorder" 分隔。 ListBox 本身也有一个页眉和一个包含一行的页脚(x:Name="ListTopBorder" 和x:Name="ListBottomBorder")。现在我需要一种方法来禁用此 ListBox 中最后一项的行 (x:Name="ItemSeparatorBorder")。
我想到了一些Visibility 绑定到x:Name="ItemSeparatorBorder" 与Converter 匹配当前项目的索引到ListBox 的总数。但我不知道如何实现它,也找不到任何好的示例。
代码应该可以在 Windows Phone 8.0 / .NET 4.0 上运行。
这是我目前的代码:
<telerikPrimitives:RadDataBoundListBox
x:Name="ListBox"
ItemsSource="{Binding Items}">
<telerikPrimitives:RadDataBoundListBox.ListHeaderTemplate>
<DataTemplate>
<Grid Height="30">
<Border
x:Name="ListTopBorder"
Height="1"
VerticalAlignment="Bottom"
Background="Blue"/>
</Grid>
</DataTemplate>
</telerikPrimitives:RadDataBoundListBox.ListHeaderTemplate>
<telerikPrimitives:RadDataBoundListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="1"></RowDefinition>
</Grid.RowDefinitions>
<controls:ListItem Margin="30,10,0,10">/>
<Border
x:Name="ItemSeparatorBorder"
Grid.Row="1"
Height="1"
Background="Blue"
Margin="30,0,0,0"/>
</Grid>
</DataTemplate>
</telerikPrimitives:RadDataBoundListBox.ItemTemplate>
<telerikPrimitives:RadDataBoundListBox.ListFooterTemplate>
<DataTemplate>
<Grid Height="30">
<Border
x:Name="ListBottomBorder"
Height="1"
VerticalAlignment="Top"
Background="Blue"/>
</Grid>
</DataTemplate>
</telerikPrimitives:RadDataBoundListBox.ListFooterTemplate>
</telerikPrimitives:RadDataBoundListBox>
如何隐藏最后一项的边框?
为了更清楚,我想在这里删除最后的蓝线:
【问题讨论】:
-
这是
Listbox的边界是吗? -
不,我想从列表的最后一项中隐藏
x:Name="ItemSeparatorBorder"。
标签: c# xaml windows-phone-8 .net-4.0 listbox