通过代码将行添加到网格 [英] Adding Rows to a Grid via code

查看:94
本文介绍了通过代码将行添加到网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好:-)



我希望你能再帮我一次。



所以我我正准备用C#和XAML编写一个WinRT应用程序。

让我举例说明它应该做什么:



我们看到3标签,3个文本框和一个Addbutton:

名称|姓氏|生日

TB1 | TB2 | TB3 | Addbutton



现在我输入我的信息。通过单击Add按钮,应用程序应该获取给定的信息,向Grid添加一个新行并在其中写入给定的信息。



我真的被困在这里......任何人都可以给我建议如何实现它?!



非常感谢!

Hello :-)

I hope you can help me out again.

So I´m about to writing a WinRT App with C# and XAML.
Let me make an example what it should doing:

We see 3 Labels, 3 Textboxes and a Addbutton:
Name | Surname | Birthday
TB1 | TB2 | TB3 | Addbutton

Now I type in my Informations as usally. By Clicking the Addbutton the App should take the given informations, append a new line to the Grid and write the given informations in it.

I get really stucked here...could any one please give me advises how to realise it?!

thanks a lot!

推荐答案

Alex - 我将采用的方法是使用一个ObservableCollection,它包含您用来包装的类的集合姓名,姓氏和生日。这个集合将是GridView中的ItemsSource - 当你向它添加一个项目时,应用程序将自动显示新元素。
Alex - the approach I would take would be to use an ObservableCollection that holds a collection of the class you are using to wrap the name, surname and birthday in. This collection will be the ItemsSource in your GridView - when you add an item to it, the application will automatically display the new element.


这篇关于通过代码将行添加到网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆