【发布时间】:2014-04-26 03:17:32
【问题描述】:
我想在 wp8 中将 3 个字符串数据绑定到表中,但不知道该怎么做。
问题是:- 我从服务器得到响应然后我将此响应解绑到字符串的例如字符串 a、字符串 b、字符串 c 我想将它们作为行显示在手机屏幕上,然后当我得到第二个响应时,我想像旧字符串一样将它们绑定在新行中(保留旧行)......以获得完整的表格
请帮助我,我尝试过这样的示例,但手机屏幕上没有出现任何数据:-
Grid Layout = new Grid();
Layout.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
Layout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50) });
Layout.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
Layout.Children.Add(new TextBlock() { });
//Read the children
foreach (UIElement element in Layout.Children)
{
//Read it's row and column property
int row = (int)element.GetValue(Grid.RowProperty);
}
//Some logic to store the row-columns of the UIElement, if required
//Then bind some data by retrieving the TextBlock
TextBlock lbl = Layout.Children[0] as TextBlock;
Binding bind = new Binding();
//logic for binding
lbl.SetBinding(TextBlock.TextProperty, bind);
【问题讨论】:
-
我已经回到原来的问题,因为它比进一步编辑更好地描述了问题。
标签: c# wpf silverlight windows-phone-8 user-controls