我有一个4列表,其中2和2是相同的列。我需要表格从左到右显示列表中的信息。 所以例如左边的“饮料”栏应该显示“A”和价格显示1.右边的“饮料”栏应该显示列表中的下一个饮料,在这个例子中它应该显示“B”和“1”,不一样左栏。它应该继续下去。列表中的下一个项目应该向下和向左等等。
实施例
Drink Price Drink Price
Karlovačko 15 Ožujsko 15
Graševina 20 etc. x
感谢您的帮助
c#code
namespace ElbaTrams_Kupac
{
/// <summary>
/// Interaction logic for AlkoholnaPica.xaml
/// </summary>
public partial class AlkoholnaPica : Page
{
public AlkoholnaPica()
{
InitializeComponent();
List<CjenikAlkohol> items = new List<CjenikAlkohol>();
items.Add(new CjenikAlkohol() { Drink = "A", Price = 1 });
items.Add(new CjenikAlkohol() { Drink = "B", Price = 2 });
items.Add(new CjenikAlkohol() { Drink = "C", Price = 3 });
alkoholCjenik.ItemsSource = items;
}
public class CjenikAlkohol
{
public string Drink { get; set; }
public int Price { get; set; }
}
}
}
XAML代码
d:DesignHeight="445" d:DesignWidth="400"
Title="AlkoholnaPica">
<Grid Background="#FF4AC1A7">
<ListView Name="alkoholCjenik" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FF042271" HorizontalAlignment="Center">
<ListView.View>
<GridView>
<GridViewColumn Header="Drink" Width="150" DisplayMemberBinding="{Binding Drink}" />
<GridViewColumn Header="Price" Width="50" DisplayMemberBinding="{Binding Price}" />
<GridViewColumn Header="Drink" Width="150" DisplayMemberBinding="{Binding Drink}" />
<GridViewColumn Header="Price" Width="50" DisplayMemberBinding="{Binding Price}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
答案 0 :(得分:0)
我在评论中遵循o_weisman的建议。将列表拆分为2个新列表。一个列表具有偶数个项目,另一个列表具有不均匀的项目。稍后我会发布代码,因为它仍然非常简单且无组织。