使用WPF的MVVM项目中的注册表形式 [英] Registration form impliment in MVVM project using WPF

查看:120
本文介绍了使用WPF的MVVM项目中的注册表形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有人,

我想开发MVVM应用程序并实施注册表格.在注册表单中使用一些按钮操作即可执行喜欢的操作:

I want to develop a MVVM application and implement a registration form . in registration form using some button action perform likes :

使用4个按钮: SAVE,UPDATE和 删除,清除记录.

显示记录在ListView或GrigView中.

and show record in ListView or GrigView .

使用MVVM

请在下面的附件图片中找到

Please find below attached image :

A.Acharya对我们的反馈在Windows Store中开发和推广您的应用程序,如果有帮助,请记住将其标记为答案,如果没有帮助,则将其取消标记.

A.Acharya Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.

推荐答案

请通过将有用的帖子标记为答案来关闭话题.

Please close your threads by marking helpful posts as answer.

该论坛不适合其他人为您开发完整的应用程序或注册表格:)如果您需要某人从头开始为您执行此操作,则应聘请开发人员.

The forums are not for anyone else to develop an entire application or registration form for you :) If you need someone to do this for you from scratch you should hire a developer.

不过,我可以给您一些指导,以帮助您入门.您可以将注册表单的DataContext属性绑定到ListView的SelectedItem.您可以在视图模型中定义一个源属性,以跟踪所选项目:

I can give you some pointers that should get you started though. You could bind the DataContext property of the registration form to the SelectedItem of the ListView. You define a source property in the view model that keeps track of the selected item:

 private Person _person;
        public Person SelectedPerson
        {
            get { return _person; }

            set
            {
                _person = value;
                NotifyPropertyChanged("SelecedPerson");
            }
        }

然后绑定显示记录"的Command属性.视图模型的ICommand属性的按钮,该属性将source属性和注册表单的根面板的DataContext直接设置为source属性:

You then bind the Command property of the "Show Record" button to an ICommand property of the view model that sets the source property and the DataContext of the root panel of the registration form directly to the source property:

<Button Content="Show Record" Command="{Binding SetSelectedPersonCommand}" />

<Grid DataContext="{Binding SelectedPerson}">
...
<TextBox Text="{Binding FirstName}" Grid.Column="1" />
...
<TextBox Text="{Binding LastName}" Grid.Row="1" Grid.Column="1" />

有关命令的更多信息,您可以通过博客文章引用:

For more information about commands you could refer to by blog post: https://blog.magnusmontin.net/2013/06/30/handling-events-in-an-mvvm-wpf-application/

在视图模型正确实现INotifyPropertyChanged接口的情况下,如果在ICommand的Execute方法中设置SelectedPerson属性,则将更新TextBoxes: https://msdn.microsoft.com/zh-CN/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx

The TextBoxes will be updated when you set the SelectedPerson property in the Execute method of the ICommand provided that the view model implements the INotifyPropertyChanged interface correctly: https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx

然后,将其他按钮的Command属性绑定到执行相应的CRUD(创建/读取/更新/删除)操作的视图模型的其他IComamnd属性.

You then bind the Command property of the other buttons to other IComamnd properties of the view model that performs the corresponding CRUD (Create/Read/Update/Delete) action.

正如我在您的另一个主题中提到的那样,与数据库的实际通信实际上不是WPF主题,但是您可以使用ADO.NET与之通信: https://msdn.microsoft.com/en-us/library/jj943772.aspx .

As I mentioned in another thread of yours, the actual communication with the database is not really a WPF topic but you could use ADO.NET to communicate with it:  https://msdn.microsoft.com/en-us/library/jj943772.aspx.

请参考其他主题以获取更多信息和链接:

Please refer to the other thread for more information and links: https://social.msdn.microsoft.com/Forums/vstudio/en-US/07c0d777-7e54-4101-b786-9dc622bb1639/registration-form-develop-in-mvvm-using-data-base?forum=wpf#07c0d777-7e54-4101-b786-9dc622bb1639

希望有帮助.

请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


这篇关于使用WPF的MVVM项目中的注册表形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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