【发布时间】:2014-08-04 06:21:13
【问题描述】:
以下代码来自我的 studentDeutils.xaml 页面。我有
<ListBox ItemsSource="{Binding}" Name="StudentDetails">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="40">
<TextBlock Text="{Binding StudentName, StringFormat='t'}" TextWrapping="Wrap" Margin="2,0,12,10" TextAlignment="Center"/>
<TextBlock Text="{Binding StudentRegNo, StringFormat='t'}" TextWrapping="Wrap" Margin="85,0,12,10" TextAlignment="Center"/>
<TextBlock Text="{Binding Address, StringFormat='t'}" TextWrapping="Wrap" Margin="175,0,12,10" TextAlignment="Center"/>
<TextBlock Text="{Binding TWD, StringFormat='t'}" TextWrapping="Wrap" Margin="365,0,12,10" TextAlignment="Center"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock x:Name="totalstudents" FontSize="24" TextAlignment="Center" FontWeight="Bold" Text="" TextWrapping="Wrap" HorizontalAlignment="Left" Width="247" />
我使用来自 studentDeatils.xaml.cs 的以下代码将数据发送到 .xaml 页面。这里的 StudentDetailsViewer 类用于显示绑定文件。
foreach (var stu in Studentdetails)
{
this.StudentsheetItems.Add(new StudentDetailsViewer()
{
StudentName = stu.StudentName,
StudentRegNo = stu.StudentRegNo,
Address= stu.Address,
TWD = stu.TWD
});
};
StudentDetails.ItemsSource = StudentsheetItems;
我想在绑定列表后查看 TextBlock(x:Name="totalstudents")。如何知道绑定Listbox会占用多少空间?
【问题讨论】:
标签: xaml windows-phone-8