Windows phone 8 如何在windows phone 8应用程序中创建表结构?
我想在windows phone 8应用程序中创建学生报告 共有3行4列 结构如下Windows phone 8 如何在windows phone 8应用程序中创建表结构?,windows-phone-8,Windows Phone 8,我想在windows phone 8应用程序中创建学生报告 共有3行4列 结构如下 student1 student2 student3 主题1 主题2 主题3 总数 标记 现在,student1、student2是学生的名字,学生的名字应该动态地来自WindowsAzure数据库。 所有的分数都在专上学生的数据库中。这些分数应该在专业学生面前展示。 所有数据都存在于数据库中。如何以表格形式显示它?我认为一个包含一些文本块的简单网格控件就可以了。您可以非常轻松地在X
student1 student2 student3
主题1
主题2
主题3
总数 标记 现在,student1、student2是学生的名字,学生的名字应该动态地来自WindowsAzure数据库。 所有的分数都在专上学生的数据库中。这些分数应该在专业学生面前展示。
所有数据都存在于数据库中。如何以表格形式显示它?我认为一个包含一些文本块的简单网格控件就可以了。您可以非常轻松地在XAML中定义它:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" ... />
<TextBlock Grid.Row="1" Grid.Column="0" ... />
<TextBlock Grid.Row="2" Grid.Column="0" ... />
...
</Grid>
...
唯一需要注意的是高度和宽度是如何定义的。基本上有3种类型的高度/宽度:
- 静态:用数字定义,以像素为单位
- 自动:由关键字Auto定义,并根据内容大小动态更改
- “填充剩余空间”:由星号*符号定义,并使行/列填充网格中剩余的可用空间
查看查看以了解更多信息。您可以设置视图,如下所示: XAML:
政务司司长:
受保护的覆盖无效OnNavigatedTo(NavigationEventArgs e)
{
基地。导航到(e);
List obj=新列表();
增加(新数据(“学生1”、“10”、“20”、“30”);
目标添加(新数据(“学生2”、“0”、“10”、“20”);
目标添加(新数据(“学生3”、“20”、“30”、“40”);
目标添加(新数据(“学生4”、“30”、“40”、“50”);
目标添加(新数据(“学生5”、“40”、“50”、“60”);
stu.ItemsSource=obj;
}
公共类数据
{
公共字符串名称{get;set;}
公共字符串s1{get;set;}
公共字符串s2{get;set;}
公共字符串s3{get;set;}
公共数据(){}
公共数据(字符串名称、字符串s1、字符串s2、字符串s3)
{
this.name=名称;
这是1.s1=s1;
这1.s2=s2;
这1.s3=s3;
}
}
在这里,您只需要拥有Azure数据库中的数据。从上面的实现中,您可以像下面一样查看学生的滚动数据。
必须使用第一个列表框作为列并设置ItemSource属性 及 对象行和set-ItemSource属性的另一个列表框
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ListBox x:Name="stu" Grid.RowSpan="4" Grid.Column="1" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="10">
<TextBlock Text="{Binding name}"></TextBlock>
<TextBlock Text="{Binding s1}" TextAlignment="Center"></TextBlock>
<TextBlock Text="{Binding s2}" TextAlignment="Center"></TextBlock>
<TextBlock Text="{Binding s3}" TextAlignment="Center"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock></TextBlock>
<TextBlock Grid.Row="1" Text="Subject1"></TextBlock>
<TextBlock Grid.Row="2" Text="Subject2"></TextBlock>
<TextBlock Grid.Row="3" Text="Subject3"></TextBlock>
</Grid>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
List<data> obj = new List<data>();
obj.Add(new data("Student1", "10", "20", "30"));
obj.Add(new data("Student2", "0", "10", "20"));
obj.Add(new data("Student3", "20", "30", "40"));
obj.Add(new data("Student4", "30", "40", "50"));
obj.Add(new data("Student5", "40", "50", "60"));
stu.ItemsSource = obj;
}
public class data
{
public string name { get; set; }
public string s1 { get; set; }
public string s2 { get; set; }
public string s3 { get; set; }
public data() { }
public data(string name, string s1, string s2, string s3)
{
this.name = name;
this.s1 = s1;
this.s2 = s2;
this.s3 = s3;
}
}