{"id":215321,"date":"2014-03-11T11:27:02","date_gmt":"2014-03-11T07:27:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=215321"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=215321","title":{"rendered":"<span class=\"post_title\">WCF RIA Services. \u0412\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d Model-View-ViewModel (MVVM). \u0427\u0430\u0441\u0442\u044c 4<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d Model-View-ViewModel (MVVM) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u0430\u0431\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 Silverlight \u0438 WPF. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 3 \u0443\u0440\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0431\u0440\u0438, \u0442\u043e MVVM \u2013 \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u0442\u0430\u043a\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a MVC \u0438 MVP \u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0438 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 Silverlight \u0438 WPF. \u041c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430 (ViewModel) \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0438\u0434\u0443 (View) \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431 \u0432\u0438\u0434 \u043c\u043e\u0433 \u043b\u0435\u0433\u043a\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434, \u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430 \u0442\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043b\u043e\u0433\u0438\u043a\u0430. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u00abDataContext\u00bb \u0440\u0430\u0432\u0435\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (binding). <\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043d\u0430\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0430 \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430, \u0447\u0442\u043e \u0433\u0440\u0443\u0431\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c, \u043a\u0430\u043a \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c \u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u043e\u043c. \u0422\u0430\u043a \u0436\u0435, \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 (unit test), \u0442\u0430\u043a \u043a\u0430\u043a \u043b\u043e\u0433\u0438\u043a\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 UI (\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f). <\/p>\n<p>  \u0418 \u043f\u043e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438, \u0432\u0441\u0442\u0443\u043f\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432 \u043d\u0430\u0448 \u0443\u0440\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. <\/p>\n<h4>\u0428\u0430\u0433 1: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430<\/h4>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u0421 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u043c\u044b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0444\u0430\u0439\u043b\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (\u0438\u043c\u044f_\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.xaml.cs). \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u044b \u043f\u043e\u0440\u043e\u0434\u0438\u043b\u0438 \u0441\u0438\u043b\u044c\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0410 \u044d\u0442\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043e\u0447\u0435\u043d\u044c \u043f\u043b\u043e\u0445\u043e\u0439 \u0442\u043e\u043d. \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f. \u0412\u044b\u043d\u0435\u0441\u0435\u043c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u00abTasksViewModel\u00bb. \u0414\u0430\u043b\u0435\u0435, \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435 \u043f\u043b\u043e\u0445\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430. \u041d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0444\u043e\u0440\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u0434\u0432\u0443\u043c \u0432\u0435\u0440\u0445\u043d\u0438\u043c TextBox \u043a\u043d\u043e\u043f\u043a\u0443 \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0430\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f DatePickers, \u0443\u0434\u0430\u043b\u0438\u043c \u0438\u0437 DataGrid \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0438 \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u043c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430. <\/p>\n<p>  \u0411\u0435\u0433\u043b\u043e \u0438\u0437\u0443\u0447\u0438\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 UI \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0448\u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430: \u0434\u0432\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 DateTime \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0434\u0430\u0442\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u0440\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u043a\u043d\u043e\u043f\u043e\u043a, \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e Tasks. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cs\">public class TasksViewModel  {      public DateTime LowerSearchDate { get; set; }      public DateTime UpperSearchDate { get; set; }      public ICommand SearchByDateCommand { get; set; }      public ICommand AddTaskCommand { get; set; }      public ICommand SaveChangesCommand { get; set; }      public IEnumerable&lt;Task&gt; Tasks { get; set; }  } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 INotifyPropertyChanged \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 UI \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445. \u0412 \u043a\u043e\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">public class TasksViewModel : INotifyPropertyChanged  {      public event PropertyChangedEventHandler PropertyChanged = delegate { };      DateTime _LowerSearchDate;      public DateTime LowerSearchDate      {          get          {              return _LowerSearchDate;          }          set          {              if (value != _LowerSearchDate)              {                  _LowerSearchDate = value;                  PropertyChanged(this, new PropertyChangedEventArgs(&quot;LowerSearchDate&quot;));              }          }      }       DateTime _UpperSearchDate;      public DateTime UpperSearchDate      {          get          {              return _UpperSearchDate;          }          set          {              if (value != _UpperSearchDate)              {                  _UpperSearchDate = value;                  PropertyChanged(this, new PropertyChangedEventArgs(&quot;UpperSearchDate &quot;));              }          }      } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 ICommand \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. \u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0435\u0449\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e RelayCommand. \u041d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c DelegateCommand, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 Prism. <\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f RelayCommand \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u00abRelayCommand\u00bb:<\/p>\n<pre><code class=\"cs\">namespace TaskManager {     public class RelayCommand&lt;T&gt; : ICommand     {         Action&lt;T&gt; _TargetExecuteMethod;         Func&lt;T, bool&gt; _TargetCanExecuteMethod;          public RelayCommand(Action&lt;T&gt; executeMethod)         {             _TargetExecuteMethod = executeMethod;         }          public RelayCommand(Action&lt;T&gt; executeMethod, Func&lt;T,bool&gt; canExecuteMethod)         {             _TargetExecuteMethod = executeMethod;             _TargetCanExecuteMethod = canExecuteMethod;         }          public void RaiseCanExecuteChanged()          {             CanExecuteChanged(this, EventArgs.Empty);          }         #region ICommand Members          bool ICommand.CanExecute(object parameter)         {             if (_TargetCanExecuteMethod != null)             {                 T tparm = (T)parameter;                 return _TargetCanExecuteMethod(tparm);             }             if (_TargetExecuteMethod != null)             {                 return true;             }             return false;         }          public event EventHandler CanExecuteChanged = delegate { };          void ICommand.Execute(object parameter)         {             if (_TargetExecuteMethod != null)             {                 _TargetExecuteMethod((T)parameter);             }         }         #endregion     } } <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0438\u0434\u0430, \u0430 DomainContext \u2013 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u0432\u043e\u0435\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438, \u0442\u043e \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 MVVM \u0432 RIA Services, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c DomainContext \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430. <\/p>\n<pre><code class=\"cs\">TasksDomainContext _Context = new TasksDomainContext();     public TasksViewModel()  {      SearchByDateCommand = new RelayCommand&lt;object&gt;(OnSearchByDate);      AddTaskCommand = new RelayCommand&lt;object&gt;(OnAddTask);      SaveChangesCommand = new RelayCommand&lt;object&gt;(OnSaveChanges);      Tasks = _Context.Tasks;      if (!DesignerProperties.IsInDesignTool)      {          _Context.Load(_Context.GetTasksQuery());      }  } <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u0432\u044b\u0448\u0435, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c TasksDomainContext \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430, \u0430 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0447\u0442\u043e \u0431 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e Tasks \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 Tasks, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0434\u043e\u043c\u0435\u043d\u0430, \u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f INotifyCollectionChanged \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u00abload\u00bb \u0438\u043b\u0438 \u00abSubmitChanges\u00bb \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abDesignerProperties.IsInDesignTool\u00bb \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432 \u0431\u043b\u043e\u043a\u0435 \u00abIf\u00bb, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u00abLoad\u00bb \u0438\u0437 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0435\u0447\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443. <\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437 MainPage.xaml.cs \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u043b\u043e\u0433\u0438\u043a\u0438. MainPage.xaml.cs \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e:<\/p>\n<pre><code class=\"cs\">namespace TasksManager {     public partial class MainPage : UserControl     {         public MainPage()         {             InitializeComponent();         } <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0443\u0440\u043e\u043a\u0435. \u041c\u0435\u0442\u043e\u0434 GetTasksByStartDate \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043b\u0438\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0443\u0436\u0431\u0435 \u0434\u043e\u043c\u0435\u043d\u0430 \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0438 \u043a\u0430\u043a \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441. \u0422\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043e\u043a\u043d\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043e\u043a\u043d\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430 \u2013 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 MVVM \u0438 \u0432\u0441\u0435 \u0435\u0433\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u044d\u0442\u0438\u0445 \u0443\u0440\u043e\u043a\u043e\u0432. \u0411\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 MVVM \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 Prism. <\/p>\n<pre><code class=\"cs\">private void OnSearchByDate(object param)  {      _Context.Tasks.Clear();      EntityQuery&lt;Task&gt; query = _Context.GetTasksQuery();      LoadOperation&lt;Task&gt; loadOp = _Context.Load(query.Where(t =&gt; t.StartDate &gt;= LowerSearchDate && t.StartDate &lt;= UpperSearchDate));  }     private void OnAddTask(object param)  {      \/\/ \u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c      \/\/ \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 MVVM \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0432\u0448\u0438\u0441\u044c \u0441 Prism 4      AddTaskView popup = new AddTaskView();      popup.DataContext = new Task();      popup.Closed += delegate      {          if (popup.DialogResult == true)          {              Task newTask = popup.DataContext as Task;              if (newTask != null) _Context.Tasks.Add(newTask);          }      };      popup.Show();  }     private void OnSaveChanges(object param)  {      _Context.SubmitChanges();  } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043e\u043a\u043d\u043e. \u041d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u00ab\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c\u00bb \u2014 \u00ab\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u00bb \u2014 \u00ab\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 Silverlight\u00bb \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u00abAddTaskView\u00bb \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"xml\">&lt;controls:ChildWindow x:Class=&quot;TaskManager.AddTaskView&quot;            xmlns=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;             xmlns:x=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;             xmlns:controls=&quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls&quot;            Width=&quot;361&quot; Height=&quot;287&quot;             Title=&quot;Add Task&quot; mc:Ignorable=&quot;d&quot; xmlns:riaControls=&quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices&quot; xmlns:my=&quot;clr-namespace:TaskManager.Web&quot; xmlns:d=&quot;http:\/\/schemas.microsoft.com\/expression\/blend\/2008&quot; xmlns:mc=&quot;http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006&quot; xmlns:sdk=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\/sdk&quot;&gt;     &lt;Grid x:Name=&quot;LayoutRoot&quot; Margin=&quot;2&quot;&gt;         &lt;Grid.RowDefinitions&gt;             &lt;RowDefinition \/&gt;             &lt;RowDefinition Height=&quot;Auto&quot; \/&gt;         &lt;\/Grid.RowDefinitions&gt;          &lt;Button x:Name=&quot;CancelButton&quot; Content=&quot;Cancel&quot; Click=&quot;CancelButton_Click&quot; Width=&quot;75&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,12,0,0&quot; Grid.Row=&quot;1&quot; \/&gt;         &lt;Button x:Name=&quot;SaveButton&quot; Content=&quot;Save&quot; Width=&quot;75&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,12,79,0&quot; Grid.Row=&quot;1&quot;                 Click=&quot;OKButton_Click&quot; \/&gt;         &lt;Grid DataContext=&quot;{Binding}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,12,0,0&quot; Name=&quot;grid1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;315&quot;&gt;             &lt;Grid.ColumnDefinitions&gt;                 &lt;ColumnDefinition Width=&quot;Auto&quot; \/&gt;                 &lt;ColumnDefinition Width=&quot;237&quot; \/&gt;                 &lt;ColumnDefinition Width=&quot;4*&quot; \/&gt;             &lt;\/Grid.ColumnDefinitions&gt;             &lt;Grid.RowDefinitions&gt;                 &lt;RowDefinition Height=&quot;Auto&quot; \/&gt;                 &lt;RowDefinition Height=&quot;Auto&quot; \/&gt;                 &lt;RowDefinition Height=&quot;Auto&quot; \/&gt;                 &lt;RowDefinition Height=&quot;100&quot; \/&gt;             &lt;\/Grid.RowDefinitions&gt;             &lt;sdk:Label Content=&quot;Description:&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;3&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3&quot; VerticalAlignment=&quot;Center&quot; \/&gt;             &lt;TextBox Grid.Column=&quot;1&quot; Grid.Row=&quot;3&quot; Height=&quot;91&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3,3,0,6&quot; Name=&quot;descriptionTextBox&quot; Text=&quot;{Binding Path=Description, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;221&quot; \/&gt;             &lt;sdk:Label Content=&quot;End Date:&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;2&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3&quot; VerticalAlignment=&quot;Center&quot; \/&gt;             &lt;controls:DatePicker Grid.Column=&quot;1&quot; Grid.Row=&quot;2&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3,3,0,3&quot; Name=&quot;endDateDatePicker&quot; SelectedDate=&quot;{Binding Path=EndDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;120&quot; \/&gt;             &lt;sdk:Label Content=&quot;Start Date:&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;1&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3&quot; VerticalAlignment=&quot;Center&quot; \/&gt;             &lt;controls:DatePicker Grid.Column=&quot;1&quot; Grid.Row=&quot;1&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3,3,0,3&quot; Name=&quot;startDateDatePicker&quot; SelectedDate=&quot;{Binding Path=StartDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;120&quot; \/&gt;             &lt;sdk:Label Content=&quot;Task Name:&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;0&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3&quot; VerticalAlignment=&quot;Center&quot; \/&gt;             &lt;TextBox Grid.Column=&quot;1&quot; Grid.Row=&quot;0&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;3,3,0,3&quot; Name=&quot;taskNameTextBox&quot; Text=&quot;{Binding Path=TaskName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, TargetNullValue=''}&quot; VerticalAlignment=&quot;Center&quot; Width=&quot;221&quot; \/&gt;         &lt;\/Grid&gt;     &lt;\/Grid&gt; &lt;\/controls:ChildWindow&gt; <\/code><\/pre>\n<p>  \u0412\u0441\u0435. \u041c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0433\u043e\u0442\u043e\u0432\u0430 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430\u0448\u0435\u0433\u043e UI.<\/p>\n<h4>\u0428\u0430\u0433 2: \u0421\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0412\u0438\u0434 \u0438 \u041c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430<\/h4>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c DomainDataSource, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u043f\u0440\u0438 \u00abdrag and drop\u00bb. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 MVVM \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 DomainDataSource, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 XAML \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f MVVM. <\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c DataContext. \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430. \u0418 \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432:<\/p>\n<pre><code class=\"xml\">&lt;UserControl x:Class=&quot;TaskManager.MainPage&quot; ...&gt;      &lt;UserControl.DataContext&gt;          &lt;local:TasksViewModel\/&gt;      &lt;\/UserControl.DataContext&gt;          &lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;White&quot;&gt;          &lt;sdk:DataGrid ItemsSource=&quot;{Binding Tasks}&quot; ...\/&gt;          &lt;Button Command=&quot;{Binding SearchByDateCommand}&quot; ...\/&gt;          &lt;Button Command=&quot;{Binding AddTaskCommand}&quot; ... \/&gt;          &lt;Button Command=&quot;{Binding SaveChangesCommand}&quot; ... \/&gt;          &lt;sdk:DatePicker SelectedDate=&quot;{Binding LowerSearchDate}&quot; ... \/&gt;          &lt;sdk:DatePicker SelectedDate=&quot;{Binding UpperSearchDate}&quot; ... \/&gt;      &lt;\/Grid&gt;  &lt;\/UserControl&gt; <\/code><\/pre>\n<h5>\n<h4>\u0412\u0438\u0434\u0435\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430<\/h4>\n<p>  <iframe loading=\"lazy\" width=\"560\" height=\"349\" src=\"\/\/www.youtube.com\/embed\/rkEsjTTRlIA?wmode=opaque\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<\/h5>\n<h4>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/h4>\n<p>  \u041d\u0430 <a href=\"https:\/\/github.com\/struggleendlessly\/Silverlight_WCF_RIA\/tree\/Part4\">Github<\/a>   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/215321\/\"> http:\/\/habrahabr.ru\/post\/215321\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d Model-View-ViewModel (MVVM) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u0430\u0431\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 Silverlight \u0438 WPF. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 3 \u0443\u0440\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0431\u0440\u0438, \u0442\u043e MVVM \u2013 \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u0442\u0430\u043a\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043a MVC \u0438 MVP \u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0438 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 Silverlight \u0438 WPF. \u041c\u043e\u0434\u0435\u043b\u044c \u0432\u0438\u0434\u0430 (ViewModel) \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0438\u0434\u0443 (View) \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431 \u0432\u0438\u0434 \u043c\u043e\u0433 \u043b\u0435\u0433\u043a\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434, \u0430 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430 \u0442\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043b\u043e\u0433\u0438\u043a\u0430. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u00abDataContext\u00bb \u0440\u0430\u0432\u0435\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (binding). <\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u043d\u0430\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0430 \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430, \u0447\u0442\u043e \u0433\u0440\u0443\u0431\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c, \u043a\u0430\u043a \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c \u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u043e\u043c. \u0422\u0430\u043a \u0436\u0435, \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 (unit test), \u0442\u0430\u043a \u043a\u0430\u043a \u043b\u043e\u0433\u0438\u043a\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 UI (\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f). <\/p>\n<p>  \u0418 \u043f\u043e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438, \u0432\u0441\u0442\u0443\u043f\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432 \u043d\u0430\u0448 \u0443\u0440\u043e\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. <\/p>\n<h4>\u0428\u0430\u0433 1: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u0438\u0434\u0430<\/h4>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-215321","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/215321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=215321"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/215321\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=215321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=215321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=215321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}