我正在尝试创建一个以表格格式显示一些信息的程序。该表的行数可以改变,因此该表可能会或可能不会在一次查看网页时完全可见。
有没有办法让我可以随着时间的推移显示部分表格?例如:显示第 1-30 行 1 分钟,然后显示第 31-50 行 1 分钟,然后再显示第 1-30 行,以此类推。
我到目前为止的代码是:
XAML:
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="InnerGrid" Grid.Row="1" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
</Grid>
using system;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Diagnostics;
namespace MyNameSpace
{
public partial class MainPage : UserControl
{
//The value of numRows will depend on a value from a database, so it may change every once in a while.
int numRows = 45;
Border border = new Border();
Border border2 = new Border();
public MainPage()
{
InitializeComponent();
createRows();
}
public Border initializeBorder(Border b)
{
b.BorderBrush = new SolidColorBrush(Colors.Black);
b.BorderThickness = new Thickness(1);
return b;
}
public void createRows()
{
//This for loop creates the necessary amount of rows.
for (int i = 0; i < numRows; i++)
{
RowDefinition rd = new RowDefinition();
rd.Height = new GridLength(20);
InnerGrid.RowDefinitions.Add(rd);
}
//This for loop creates and applies the borders that make the table "appear"
for (int i = 0; i < numRows; i++)
{
Border b = new Border();
Border b2 = new Border();
Grid.SetColumn(initializeBorder(b), i);
Grid.SetRow(initializeBorder(b2), i);
Grid.SetColumnSpan(b, 11);
Grid.SetColumnSpan(b2, 11);
Grid.SetRowSpan(b, numRows);
Grid.SetRowSpan(b2, numRows);
InnerGrid.Children.Add(b);
InnerGrid.Children.Add(b2);
}
}
}
}