0

我需要在 ListBox 底部有多个列和 2 个按钮和一行,例如:

项目 1 项目 2 项目 3 项目 4 按钮 1 按钮 2
-------------------------------------------------------- ---------

谢谢

- - - 更新

有一行显示每一列的标题

标题1 标题2 标题3 标题4

项目 1 项目 2 项目 3 项目 4 按钮 1 按钮 2
-------------------------------------------------------- ---------

-  更新
<ListBox Horizo​​ntalAlignment="Left" VerticalAlignment="Top" Margin="700,210,0,0" Name="listBox1" Width="650" Height="532" ScrollViewer.VerticalScrollBarVisibility="Auto"> <ListBox.ItemTemplate> <数据模板> <网格宽度=“650”> <Grid.ColumnDefinitions> <列定义宽度=“80”> <ColumnDefinition 宽度="*"> <ColumnDefinition 宽度="*"> <ColumnDefinition 宽度="*"> <ColumnDefinition 宽度="*"> </Grid.ColumnDefinitions> <堆栈面板> <TextBlock Margin="8,3,0,0" FontSize="22" Foreground="DarkGray" Text="商品代码"/> <TextBlock Margin="8,3,0,0" FontSize="22" Foreground="DarkGray" Text="Description" TextWrapping="Wrap"/> <TextBlock Margin="8,3,0,0" FontSize="22" Foreground="DarkGray" Text="Unit Price"/> <TextBlock Margin="8,3,0,0" FontSize="22" Foreground="DarkGray" Text="Amount"/> </堆栈面板> <TextBlock Margin="3,3,10,0" FontSize="22" FontWeight="SemiBold" Foreground="DarkBlue" Text="{Binding No}" Grid.Column="0" /> <TextBlock Margin="8,3,10,0" FontSize="22" Foreground="DarkBlue" Text="{绑定描述}" TextWrapping="Wrap" Grid.Column="1" /> <TextBlock Margin="8,3,10,0" FontSize="22" Foreground="DarkBlue" Text="{Binding UnitPrice}" TextWrapping="Wrap" Grid.Column="2" /> <TextBlock Margin="8,3,10,0" FontSize="22" Foreground="DarkBlue" Text="{Binding LineAmount}" TextWrapping="Wrap" Grid.Column="3" /> <Button x:Name="btnTransEdit" Margin="20,3,0,0" Content="Edit" FontSize="23" Horizo​​ntalAlignment="Left" VerticalAlignment="Top" Height="59" Width="130" Grid.Column="4" /> </网格> </数据模板> </ListBox.ItemTemplate>
4

1 回答 1

1

如果你使用 aLongListSelector而不是 a ,你可以很容易地做到这一点ListBox

<phone:LongListSelector ItemsSource="{Binding Items}">
    <phone:LongListSelector.ListHeader>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <TextBlock Text="Item code" Grid.Column="0" TextWrapping="Wrap" />
            <TextBlock Text="Desc" Grid.Column="1" TextWrapping="Wrap" />
            <TextBlock Text="Unit Price" Grid.Column="2" TextWrapping="Wrap" />
            <TextBlock Text="Amount" Grid.Column="3" />
        </Grid>
    </phone:LongListSelector.ListHeader>

    <phone:LongListSelector.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <TextBlock Text="{Binding No}" Grid.Column="0" TextWrapping="Wrap" />
                <TextBlock Text="{Binding Description}" Grid.Column="1" TextWrapping="Wrap" />
                <TextBlock Text="{Binding UnitPrice}" Grid.Column="2" TextWrapping="Wrap" />
                <TextBlock Text="{Binding LineAmount}" Grid.Column="3" TextWrapping="Wrap" />

                <Button Content="Edit" Grid.Column="4" />
                <Button Content="Delete" Grid.Column="5" />
            </Grid>
        </DataTemplate>
    </phone:LongListSelector.ItemTemplate>

    <phone:LongListSelector.ListFooter>
        <Grid Background="white" Height="2" Margin="0,12" />
    </phone:LongListSelector.ListFooter>
</phone:LongListSelector>
于 2013-10-16T13:34:09.053 回答