如何在WPF应用程序中动态创建表单?
我对在C#中编程WPF应用程序的编程非常陌生,并想知道最好的方法是什么:
我有一个未知数的名称列表,显示在列表框中它显示可以填写然后保存的表单,然后在单击下一个名称时会显示一个新的空白表单以填写,但是如果我返回到任何以前的表单,它将显示上次输入的信息。
我只是在寻找一个基本答案,因为我知道这是一个很长的问题。
感谢您在Advanced中的所有帮助!
I'm pretty new to programming WPF applications in C# and wondering the what the best method is to do the following:
I have a list of an unknown number of names displayed in a list box and want to have a way that when one is clicked it displays a form that can be filled in then saved, then when the next name is clicked it displays a new blank form to fill out, but if I return to any previous form it will display the information last entered.
I'm only looking for a basic answer as I know its quite a long winded question.
Thank you for all the help in advanced!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这是一个不清楚的问题,但是我现在正在研究一个类似的项目,这就是为什么我要回答的原因。您说“想有一种方法,当一个人是单击时,它会显示一个表单” ,我想您应该创建类(让它称为myClass),该类有一些属性您将使用并显示在
ListBox
中,例如按钮
,您可以通过dataTemplate
进行操作,并将列表框绑定到observableCollection&lt< t>
您的myClass对象的listbox
将自动更新或从那里添加或删除某些内容,不要忘记使用viewmodel和命令
>按钮 s。对于您的问题的一部分,我认为您可以创建从窗口类继承的类myform,这将具有项目所需的属性。例如,您想将文本保存在您的表单中,这些文本第二次单击按钮时将显示。然后,您可以创建MyForm类对象的列表,并使用XML序列化将它们保存在文件中,从而保存对象的每个属性,并且可以基于此编写逻辑。
I know this is an unclear question, but I am working on a similar project right now, that's why I gonna try to answer. You say "want to have a way that when one is clicked it displays a form", I guess you should create class(let call it MyClass) that has some properties which you will use and is displayed in
ListBox
likeButton
, you can do it byDataTemplate
and bind your ListBox toObservableCollection<T>
of your MyClass objects so yourListBox
would automatically update when you add or remove something from there, don't forget to use ViewModel andCommands
for youButton
s. For form part of your question, I think you can create class MyForm that is inherited from window class, that would have properties required for your project. For example you want to save text in your form that will be displayed when you click button second time.Then you can create List of MyForm class objects and save them in file with xml serialization that will save every property of your object and you can write logic based on this.