{"id":344,"date":"2012-08-19T12:27:36","date_gmt":"2012-08-19T03:27:36","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2012\/08\/19\/silverlight_prism_mvvm_2_mvvm\/"},"modified":"2012-08-19T12:27:36","modified_gmt":"2012-08-19T03:27:36","slug":"silverlight_prism_mvvm_2_mvvm","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2012\/08\/19\/silverlight_prism_mvvm_2_mvvm\/","title":{"rendered":"Silverlight Prism \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u5229\u7528\u3057\u3066MVVM\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b \u7b2c2\u56de MVVM\u30d1\u30bf\u30fc\u30f3\u306e\u4f5c\u6210"},"content":{"rendered":"<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/gg430869(v=pandp.40)\">MVVM QuickStart<\/a> \u3092\u53c2\u8003\u306b\u3057\u3064\u3064\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u3001Prism \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u9069\u7528\u3055\u305b\u3066\u3044\u304f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2012\/08\/18\/silverlight_prism_mvvm_1\">Silverlight Prism \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u5229\u7528\u3057\u3066MVVM\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b \u7b2c1\u56de<\/a> \u3067\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5206\u5272\u3068\u3001UI\u5408\u6210\u306e\u52d5\u4f5c\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u3067\u304d\u305f\u306e\u3067\u3001\u4eca\u56de\u306f\u3001MVVM\u30d1\u30bf\u30fc\u30f3\u3068\u5404\u30af\u30e9\u30b9\u306e\u8cac\u52d9\u3092\u518d\u78ba\u8a8d\u3057\u305f\u306e\u3061\u3001\u30c7\u30fc\u30bf\u306e\u53c2\u7167\u3092\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u3092\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3002<\/p>\n<h2>\u30af\u30e9\u30b9\u306e\u8cac\u4efb\u3068\u7279\u5fb4<\/h2>\n<p>Model-View-ViewModel(MVVM) \u30d1\u30bf\u30fc\u30f3\u306f\u3001\u30d3\u30b8\u30cd\u30b9\u304a\u3088\u3073\u30d7\u30ec\u30bc\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3092\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u304b\u3089\u660e\u78ba\u306b\u5206\u96e2\u3059\u308b\u52a9\u3051\u306b\u306a\u308b\u3002<\/p>\n<p>MVVM\u30d1\u30bf\u30fc\u30f3\u3067\u306f\u30013\u3064\u306e\u30af\u30e9\u30b9\u306b\u8cac\u52d9\u3092\u5206\u96e2\u3059\u308b\u3002<\/p>\n<ul>\n<li>View : UI\u304a\u3088\u3073UI\u30ed\u30b8\u30c3\u30af\u3092\u30ab\u30d7\u30bb\u30eb\u5316 <\/li>\n<li>View Model : \u30d7\u30ec\u30bc\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u3068\u72b6\u614b\u3092\u30ab\u30d7\u30bb\u30eb\u5316 <\/li>\n<li>Model : \u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u3068\u30c7\u30fc\u30bf\u3092\u30ab\u30d7\u30bb\u30eb\u5316 <\/li>\n<\/ul>\n<p>View \u306f View Mode\uff4c \u3068 \u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3001\u30b3\u30de\u30f3\u30c9\u3001\u901a\u77e5\u30a4\u30d9\u30f3\u30c8\u3092\u901a\u3057\u3066\u5f71\u97ff\u3057\u5408\u3046\u3002View Model\u306f\u3001\u554f\u3044\u5408\u308f\u305b\u3001\u76e3\u8996\u3057\u3001\u8abf\u6574\u3001\u66f4\u65b0\u3092\u30e2\u30c7\u30eb\u306b\u884c\u3046\u3002\u5909\u63db\u3001\u59a5\u5f53\u6027\u691c\u67fb\u3001\u30c7\u30fc\u30bf\u306e\u51dd\u96c6\u306f\u5fc5\u8981\u306b\u5fdc\u3058\u3001View\u3067\u884c\u3046\u3002<\/p>\n<p><strong>MVVM \u30af\u30e9\u30b9\u3068\u76f8\u4e92\u4f5c\u7528<\/strong><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson12.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"prism_handson12\" border=\"0\" alt=\"prism_handson12\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson12_thumb.png\" width=\"464\" height=\"138\" \/><\/a> <\/p>\n<h3>View \u30af\u30e9\u30b9<\/h3>\n<p>View\u306e\u8cac\u52d9\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u3078\u30b9\u30af\u30ea\u30fc\u30f3\u4e0a\u306e\u69cb\u9020\u3068\u898b\u3048\u65b9\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3002\u7406\u60f3\u7684\u306b\u306f\u3001\u30b3\u30fc\u30c9\u30d3\u30cf\u30a4\u30f3\u30c9\u3067\u306f\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067InitializeComponent \u30e1\u30bd\u30c3\u30c9\u306e\u307f\u3092\u547c\u3073\u51fa\u3059\u3088\u3046\u306b\u3059\u308b\u3002\u3044\u304f\u3064\u304b\u306e\u5834\u5408\u3001\u30b3\u30fc\u30c9\u30d3\u30cf\u30a4\u30f3\u30c9\u306f\u3001XAML\u3067\u306f\u8868\u73fe\u304c\u56f0\u96e3\u306a\u632f\u308b\u821e\u3044\u3092UI\u30ed\u30b8\u30c3\u30af\u3068\u3057\u3066\u542b\u3080\u3002<\/p>\n<p>View\u306e\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u5f0f\u306f\u3001\u30c7\u30fc\u30bf\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u3064\u3044\u3066\u8a55\u4fa1\u3055\u308c\u308b\u3002MVVM\u3067\u306f\u3001View\u306e\u30c7\u30fc\u30bf\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u306f\u3001View Model\u304c\u8a2d\u5b9a\u3055\u308c\u308b\u3002View Model \u306f\u3001View\u304c\u30d0\u30a4\u30f3\u30c9\u3084\u901a\u77e5\u3067\u304d\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u30b3\u30de\u30f3\u30c9\u304c\u5b9f\u88c5\u3055\u308c\u308b\u3002\u901a\u5e38\u3001\u4e00\u5bfe\u4e00\u306e\u95a2\u9023\u304cView\u3068View Model\u306b\u8a2d\u5b9a\u3055\u308c\u308b\u3002<\/p>\n<p>\u901a\u5e38\u3001View \u306f\u3001Control \u3082\u3057\u304f\u306f UserControl \u306e\u6d3e\u751f\u30af\u30e9\u30b9\u3002\u3057\u304b\u3057\u306a\u304c\u3089\u3001\u3044\u304f\u3064\u304b\u306e\u5834\u5408\u3001View \u306f\u3001\u30c7\u30fc\u30bf\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3057\u3066\u8868\u73fe\u3055\u308c\u308b\u3002<\/p>\n<h3>View Model \u30af\u30e9\u30b9<\/h3>\n<p>MVVM\u306b\u3066\u3001View Model \u306f\u3001View\u306e\u305f\u3081\u306e\u30d7\u30ec\u30bc\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u30ed\u30b8\u30c3\u30af\u304a\u3088\u3073\u30c7\u30fc\u30bf\u3092\u30ab\u30d7\u30bb\u30eb\u5316\u3059\u308b\u3002View Model \u306f\u3001\u76f4\u63a5 View\u3078\u306e\u53c2\u7167\u306f\u6301\u305f\u306a\u3044\u3057\u3001View \u306e\u5b9f\u88c5\u3084\u578b\u306b\u3064\u3044\u3066\u3082\u4f55\u3082\u77e5\u3089\u306a\u3044\u3002View Model \u306f\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30de\u30f3\u30c9\u3092\u3001View\u3068\u306e\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c9\u3084\u30a4\u30d9\u30f3\u30c8\u3092\u901a\u3058\u305f\u72b6\u614b\u306e\u5909\u66f4\u901a\u77e5\u3092\u53ef\u80fd\u306b\u3059\u308b\u305f\u3081\u306b\u5b9f\u88c5\u3059\u308b\u3002<\/p>\n<p>View Model \u306f\u3001View \u3068 Model \u3068\u306e\u76f8\u4e92\u4f5c\u7528\u306e\u8abf\u6574\u306b\u8cac\u4efb\u3092\u6301\u3064\u3002\u4e00\u822c\u7684\u306b\u3053\u308c\u306f\u3001\u4e00\u5bfe\u591a\u306e\u95a2\u4fc2\u3068\u306a\u308b\u3002<\/p>\n<h3>Model \u30af\u30e9\u30b9<\/h3>\n<p>MVVM\u306b\u3066\u3001Model \u306f\u3001\u30d3\u30b8\u30cd\u30b9\u30ed\u30b8\u30c3\u30af\u3068\u30c7\u30fc\u30bf\u3092\u30ab\u30d7\u30bb\u30eb\u5316\u3059\u308b\u3002\u901a\u5e38\u3001Model\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u30c9\u30e1\u30a4\u30f3\u30e2\u30c7\u30eb\u3092\u8868\u73fe\u3059\u308b\u3002Model \u306f\u3001\u30c7\u30fc\u30bf\u30a2\u30af\u30bb\u30b9\u3068\u30ad\u30e3\u30c3\u30b7\u30f3\u30b0\u306e\u30b5\u30dd\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u542b\u3080\u3002<\/p>\n<p>\u901a\u5e38\u3001Model \u306f\u3001View \u3068\u306e\u30d0\u30a4\u30f3\u30c9\u304c\u5bb9\u6613\u306b\u306a\u308b\u6a5f\u80fd\u3092\u5b9f\u88c5\u3059\u308b\u3002\u3053\u308c\u306f\u3001\u901a\u5e38\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u5909\u66f4\u304c\u3001<strong>INotifyPropertyChanged\u3001INotifyCollectionChanged <\/strong>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u901a\u3057\u3066\u901a\u77e5\u3055\u308c\u308b\u3053\u3068\u3092\u610f\u5473\u3059\u308b\u3002Model \u30af\u30e9\u30b9\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u3001<strong>ObservableCollection&lt;T&gt; <\/strong>\u3067\u8868\u73fe\u3059\u308b\u3002\u3053\u308c\u306f\u3001<strong>INotifyCollectionChanged <\/strong>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>Model \u306f\u3001\u30c7\u30fc\u30bf\u306e\u59a5\u5f53\u6027\u691c\u67fb\u3084\u30a8\u30e9\u30fc\u5831\u544a\u3092\u3001<strong>IDataErrorInfo<\/strong>( \u3082\u3057\u304f\u306f <strong>INotifyDataErrorInfo<\/strong>) \u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u3002<\/p>\n<h2>Model-View-ViewModel \u306e\u4f5c\u6210<\/h2>\n<p>\u3068\u3001MVVM\u306b\u304a\u3051\u308b\u3001\u5404\u30af\u30e9\u30b9\u306e\u8cac\u52d9\u3092\u6982\u89b3\u3057\u305f\u3068\u3053\u308d\u3067\u3001\u4eca\u56de\u3001<a href=\"http:\/\/typea-service.appspot.com\/fp\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5de5\u6570\u898b\u7a4d\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8<\/a>\u3092Silverlight\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u3092\u984c\u6750\u3068\u3057\u3066\u3044\u308b\u3001\u5bfe\u8c61\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u300d\u306e\u90e8\u5206\u3092\u53c2\u7167\u3059\u308b\u90e8\u5206\u3092\u5b9f\u88c5\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3046\u3002<\/p>\n<p><a href=\"http:\/\/typea-service.appspot.com\/fp\">\u984c\u6750<\/a>\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u958b\u767a\u5de5\u6570\u3092<a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4822281442\/ref=as_li_ss_tl?ie=UTF8&amp;camp=247&amp;creative=7399&amp;creativeASIN=4822281442&amp;linkCode=as2&amp;tag=typea-pm-22\">\u30d5\u30a1\u30f3\u30af\u30b7\u30e7\u30f3\u30dd\u30a4\u30f3\u30c8\u6cd5<\/a><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom-style: none !important; border-right-style: none !important; margin: 0px; border-top-style: none !important; border-left-style: none !important\" border=\"0\" alt=\"\" src=\"http:\/\/www.assoc-amazon.jp\/e\/ir?t=typea-pm-22&amp;l=as2&amp;o=9&amp;a=4822281442\" width=\"1\" height=\"1\" \/> \u3092\u4f7f\u3063\u3066\u898b\u7a4d\u3082\u308b\u3068\u3044\u3046\u3082\u306e\u3067\u3001GAE\u3092\u5229\u7528\u3057\u3066\u4f5c\u3063\u3066\u3042\u308b<\/p>\n<p> <a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4822281442\/ref=as_li_ss_il?ie=UTF8&amp;camp=247&amp;creative=7399&amp;creativeASIN=4822281442&amp;linkCode=as2&amp;tag=typea-pm-22\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/ws.assoc-amazon.jp\/widgets\/q?_encoding=UTF8&amp;ASIN=4822281442&amp;Format=_SL110_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea-pm-22\" \/><\/a><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom-style: none !important; border-right-style: none !important; margin: 0px; border-top-style: none !important; border-left-style: none !important\" border=\"0\" alt=\"\" src=\"http:\/\/www.assoc-amazon.jp\/e\/ir?t=typea-pm-22&amp;l=as2&amp;o=9&amp;a=4822281442\" width=\"1\" height=\"1\" \/>   <\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson13.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"prism_handson13\" border=\"0\" alt=\"prism_handson13\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson13_thumb.png\" width=\"298\" height=\"156\" \/><\/a> <\/p>\n<h3>Model \u306e\u4f5c\u6210<\/h3>\n<p>\u307e\u305a\u306f\u3001\u5de5\u6570\u7b97\u51fa\u5bfe\u8c61\u3067\u3042\u308b\u3001Project \u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3002<\/p>\n<pre class=\"prettyprint linenums\">namespace ProjectModule.Models\r\n{\r\n    public class Project\r\n    {\r\n        public string Key { get; set; }\r\n        public string Owner { get; set; }\r\n        public string SystemName { get; set; }\r\n        public string ApplicationName { get; set; }\r\n        public string MesurementType { get; set; }\r\n    }\r\n}<\/pre>\n<p>\u305d\u3057\u3066\u3001Project \u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u8868\u73fe\u3059\u308b\u305f\u3081\u306b\u3001Projecs \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">using System.Collections.ObjectModel;\r\n\r\nnamespace ProjectModule.Models\r\n{\r\n    public class Projects : ObservableCollection<project>\r\n    {\r\n    }\r\n}<\/pre>\n<h3>\u30c7\u30fc\u30bf\u30b5\u30fc\u30d3\u30b9\u306e\u4f5c\u6210<\/h3>\n<p>Project \u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u30c7\u30fc\u30bf\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\u3002\u73fe\u6642\u70b9\u3067\u306f\u3001\u30c0\u30df\u30fc\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u3002<\/p>\n<p><strong>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9<\/strong><\/p>\n<pre class=\"prettyprint linenums\">using ProjectModule.Models;\r\n\r\nnamespace ProjectModule.Services\r\n{\r\n    public interface IProjectDataService\r\n    {\r\n        Projects GetProjects();\r\n    }\r\n}<\/pre>\n<p><strong>\u30c0\u30df\u30fc\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u5b9f\u88c5<\/strong><\/p>\n<p>DI\u30b3\u30f3\u30c6\u30ca\u306b\u8a8d\u8b58\u3055\u305b\u308b\u305f\u3081\u306b\u3001Export \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u3002\u3053\u3053\u3067\u306f\u3001\u307e\u3060\u3001\u30c0\u30df\u30fc\u30c7\u30fc\u30bf\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u3002Web\u30b5\u30fc\u30d3\u30b9\u3068\u306e\u9023\u643a\u306f\u5225\u9014\u5b9f\u88c5\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">using System.ComponentModel.Composition;\r\nusing ProjectModule.Models;\r\n\r\nnamespace ProjectModule.Services\r\n{\r\n    [Export(typeof(IProjectDataService))]\r\n    public class ProjectDataService : IProjectDataService\r\n    {\r\n        private Projects projects;\r\n\r\n        public Projects GetProjects()\r\n        {\r\n            if (this.projects == null)\r\n            {\r\n                this.projects = new Projects { \r\n                    new Project(){\r\n                        Key = &quot;001&quot;,\r\n                        SystemName = &quot;Sys1&quot;,\r\n                        ApplicationName=&quot;Test App1&quot;\r\n                    },\r\n                          :\r\n                };\r\n            }\r\n            return this.projects;\r\n        }\r\n\r\n    }\r\n}<\/pre>\n<h3>ViewModel\u306e\u4f5c\u6210<\/h3>\n<p>INotifyChanged \u3092\u5b9f\u88c5\u3057\u3001ImportingConstructor \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3092\u884c\u3044\u3001\u4e0a\u8a18\u3067\u4f5c\u6210\u3057\u305f\u3001\u30c7\u30fc\u30bf\u30b5\u30fc\u30d3\u30b9\u3092\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3059\u308b\u3002<\/p>\n<p>\u307e\u305f\u3001ViewModel \u81ea\u4f53\u3082\u3001View \u306b\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3059\u308b\u305f\u3081\u306b\u3001Export \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3092\u4ed8\u4e0e\u3057\u3001DI\u30b3\u30f3\u30c6\u30ca\u306b\u767b\u9332\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre class=\"prettyprint linenums\">using System;\r\nusing System.ComponentModel;\r\nusing System.ComponentModel.Composition;\r\nusing System.Windows.Data;\r\nusing Microsoft.Practices.Prism.Events;\r\nusing ProjectModule.Events;\r\nusing ProjectModule.Models;\r\nusing ProjectModule.Services;\r\n\r\nnamespace ProjectModule.ViewModels\r\n{\r\n    \r\n    [Export]\r\n    public class ProjectListViewModel : INotifyPropertyChanged\r\n    {\r\n        private readonly IEventAggregator eventAggregator;\r\n        public ICollectionView Projects { get; private set; }\r\n\r\n        [ImportingConstructor]\r\n        public ProjectListViewModel(IProjectDataService dataService, IEventAggregator eventAggregator)\r\n        {\r\n            if (dataService == null) throw new ArgumentNullException(&quot;dataService&quot;);\r\n            if (eventAggregator == null) throw new ArgumentNullException(&quot;eventAggregator&quot;);\r\n\r\n            this.eventAggregator = eventAggregator;\r\n\r\n            this.Projects = new PagedCollectionView(dataService.GetProjects());\r\n            this.Projects.CurrentChanged += new EventHandler(this.SelectedProjectChanged);\r\n        }\r\n\r\n\r\n        private void SelectedProjectChanged(object sender, EventArgs e)\r\n        {\r\n            Project project = this.Projects.CurrentItem as Project;\r\n            if (project != null)\r\n            {\r\n                this.eventAggregator.GetEvent&lt;ProjectSelectedEvent&gt;().Publish(project.Key);\r\n            }\r\n        }\r\n        \r\n        #region INotifyPropertyChanged Members\r\n\r\n        public event PropertyChangedEventHandler PropertyChanged;\r\n\r\n        private void NotifyPropertyChanged(string propertyName)\r\n        {\r\n            if (this.PropertyChanged != null)\r\n            {\r\n                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));\r\n            }\r\n        }\r\n        \r\n        #endregion\r\n\r\n    }\r\n}<\/pre>\n<h3>View\u306e\u4f5c\u6210<\/h3>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2012\/08\/18\/silverlight_prism_mvvm_1\">\u524d\u56de Hello Word \u3068\u3057\u3066\u3044\u305f<\/a>\u3001ProjectList \u3092 ProjectListView \u306b \u30ea\u30cd\u30fc\u30e0\u3057\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3092\u914d\u7f6e\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u3001Project \u30af\u30e9\u30b9 \u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u30d0\u30a4\u30f3\u30c9\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson14.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"prism_handson14\" border=\"0\" alt=\"prism_handson14\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson14_thumb.png\" width=\"309\" height=\"145\" \/><\/a> <\/p>\n<pre class=\"prettyprint linenums\">&lt;UserControl x:Class=&quot;ProjectModule.Views.ProjectListView&quot;\r\n             xmlns=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;\r\n             xmlns:x=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;\r\n             xmlns:Controls=&quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data&quot;\r\n             xmlns:prism=&quot;http:\/\/www.codeplex.com\/prism&quot;&gt;\r\n    &lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;White&quot;&gt;\r\n        &lt;Grid.ColumnDefinitions&gt;\r\n            &lt;ColumnDefinition Width=&quot;*&quot; \/&gt;\r\n            &lt;ColumnDefinition Width=&quot;*&quot; \/&gt;\r\n        &lt;\/Grid.ColumnDefinitions&gt;\r\n        &lt;Grid.RowDefinitions&gt;\r\n            &lt;RowDefinition Height=&quot;Auto&quot; \/&gt;\r\n            &lt;RowDefinition Height=&quot;*&quot; \/&gt;\r\n            &lt;RowDefinition Height=&quot;Auto&quot; \/&gt;\r\n        &lt;\/Grid.RowDefinitions&gt;\r\n\r\n        &lt;TextBlock Grid.Row=&quot;0&quot; Text=&quot;Projects List View&quot; TextWrapping=&quot;Wrap&quot; Grid.RowSpan=&quot;1&quot; Grid.ColumnSpan=&quot;2&quot; FontSize=&quot;18&quot; Foreground=&quot;#FF2F3806&quot; Margin=&quot;8,8,8,8&quot; \/&gt;\r\n\r\n        &lt;Controls:DataGrid x:Name=&quot;ProjectsList&quot; Grid.Row=&quot;1&quot; Grid.Column=&quot;0&quot; Grid.ColumnSpan=&quot;2&quot; SelectionMode=&quot;Single&quot;\r\n                           ItemsSource=&quot;{Binding Path=Projects}&quot; AutoGenerateColumns=&quot;False&quot; Margin=&quot;8&quot;\r\n                           AutomationProperties.AutomationId=&quot;ProjectsListGrid&quot;&gt;\r\n            &lt;Controls:DataGrid.Columns&gt;\r\n                &lt;Controls:DataGridTextColumn Header=&quot;System Name&quot; Binding=&quot;{Binding Path=SystemName}&quot; IsReadOnly=&quot;True&quot; Width=&quot;*&quot; \/&gt;\r\n                &lt;Controls:DataGridTextColumn Header=&quot;App Name&quot; Binding=&quot;{Binding Path=ApplicationName}&quot; IsReadOnly=&quot;True&quot; Width=&quot;*&quot; \/&gt;\r\n            &lt;\/Controls:DataGrid.Columns&gt;\r\n        &lt;\/Controls:DataGrid&gt;\r\n    &lt;\/Grid&gt;\r\n&lt;\/UserControl&gt;<\/pre>\n<\/p>\n<p>\u3042\u3068\u306f\u3001\u30b3\u30fc\u30c9\u30d3\u30cf\u30a4\u30f3\u30c9\u306b\u3066\u3001\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306b\u3001ImportingConstructor \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3092\u8a2d\u5b9a\u3057\u3001\u4e0a\u8a18\u3067\u4f5c\u6210\u3057\u305f\u3001ViewModel \u3092 \u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3057\u3001\u30c7\u30fc\u30bf\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u8a2d\u5b9a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3002<\/p>\n<pre class=\"prettyprint linenums\">using System.ComponentModel.Composition;\r\nusing System.Windows.Controls;\r\nusing ProjectModule.ViewModels;\r\n\r\nnamespace ProjectModule.Views\r\n{\r\n    [Export(typeof(ProjectListView))]\r\n    public partial class ProjectListView : UserControl\r\n    {\r\n        [ImportingConstructor]\r\n        public ProjectListView(ProjectListViewModel viewModel)\r\n        {\r\n            InitializeComponent();\r\n\r\n            this.DataContext = viewModel;\r\n        }\r\n    }\r\n}<\/pre>\n<h3>\u5b9f\u884c<\/h3>\n<p>\u307e\u305a\u306f\u3001\u60f3\u5b9a\u3069\u304a\u308a\u306b\u753b\u9762\u8868\u793a\u3067\u304d\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson15.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"prism_handson15\" border=\"0\" alt=\"prism_handson15\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/SilverlightPrismMVVM2_116B9\/prism_handson15_thumb.png\" width=\"342\" height=\"283\" \/><\/a><\/p>\n<p><iframe style=\"width: 120px; height: 240px\" marginheight=\"0\" src=\"http:\/\/rcm-jp.amazon.co.jp\/e\/cm?lt1=_blank&amp;bc1=FFFFFF&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=typea-pm-22&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=ss_til&amp;asins=4873115655\" frameborder=\"0\" marginwidth=\"0\" scrolling=\"no\"><\/iframe><iframe style=\"width: 120px; height: 240px\" marginheight=\"0\" src=\"http:\/\/rcm-jp.amazon.co.jp\/e\/cm?lt1=_blank&amp;bc1=FFFFFF&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=typea-pm-22&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=ss_til&amp;asins=4894712288\" frameborder=\"0\" marginwidth=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MVVM QuickStart \u3092\u53c2\u8003\u306b\u3057\u3064\u3064\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u3001Prism \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u9069\u7528\u3055\u305b\u3066\u3044\u304f\u3002 Silverlight Prism \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u5229\u7528\u3057\u3066MVVM\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b \u7b2c1\u56de [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[55,54],"tags":[],"class_list":["post-344","post","type-post","status-publish","format-standard","hentry","category-prism","category-silverlight"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/344","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=344"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/344\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=344"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=344"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}