{"id":7627,"date":"2015-12-19T01:21:24","date_gmt":"2015-12-18T07:21:24","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=7627"},"modified":"2015-12-19T01:24:41","modified_gmt":"2015-12-18T16:24:41","slug":"jxug-%e3%81%a7%e8%a9%b1%e3%81%97%e3%81%9f-mvvm-%e3%81%ae%e6%b4%bb%e7%94%a8%e3%81%ae%e8%a7%a3%e8%aa%ac%e3%82%92","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/7627","title":{"rendered":"JXUG \u3067\u8a71\u3057\u305f MVVM \u306e\u6d3b\u7528\u306e\u89e3\u8aac\u3092"},"content":{"rendered":"<p>JXUGC #9 Xamarin.Forms Mvvm \u5b9f\u88c5\u65b9\u6cd5 Teachathon &#8211; connpass<br \/>\n<a href=\"http:\/\/jxug.connpass.com\/event\/22840\/\">http:\/\/jxug.connpass.com\/event\/22840\/<\/a><\/p>\n<p>\u306b\u3066\u3001\u7530\u6df5\u3055\u3093\u30b3\u30fc\u30c9\u306b\u300c\u30de\u30b5\u30ab\u30ea\u300d\u3092\u6295\u3052\u307e\u304f\u3063\u3066\u6765\u307e\u3057\u305f\u3002\u5b9f\u306f\u3001\u30d4\u30a2\u30ec\u30d3\u30e5\u30fc\u3068\u3044\u3046\u624b\u6cd5\u304c\u3042\u3063\u3066\u3001\u3067\u304d\u308b\u3060\u3051\u304d\u3081\u7d30\u304b\u304f\u30b3\u30fc\u30c9\u3092\u30ec\u30d3\u30e5\u30fc\u3057\u3066\u3044\u304f\u3068\u3044\u3046\u624b\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\u672c\u6765\u306a\u3089\u3070\u30a4\u30f3\u30b9\u30da\u30af\u30b7\u30e7\u30f3\u306e\u5f62\u5f0f\u3092\u4f7f\u3046\u306e\u3067\u3059\u304c\u3001\u300c\u4eba\u3092\u653b\u6483\u3059\u308b\u300d\u306e\u3067\u306f\u306a\u304f\u3066\u3001\u30b3\u30fc\u30c9\u306e\u307f\u3092\u30d0\u30b7\u30d0\u30b7\u3068\u53e9\u3044\u3066\u5411\u4e0a\u3055\u305b\u308b\u65b9\u6cd5\u3067\u3059\u306d\u3002\u30b3\u30fc\u30c9\u3092\u500b\u4eba\u306e\u6210\u679c\u7269\u3067\u306f\u306a\u304f\u3066\u3001\u5171\u540c\u306e\u6210\u679c\u7269\u3068\u3057\u3066\u4ed5\u7acb\u3066\u3042\u3052\u308b\u3053\u3068\u304c\u6700\u7d42\u76ee\u6a19\u3067\u3059\u3002<\/p>\n<p>\u3072\u3068\u307e\u305a\u3001MVVM \u3068\u306f\u4f55\u305e\uff1f\u306a\u308a\u3001Xamarin.Forms \u3068\u306f\uff1f\u3068\u3044\u3046\u8a71\u306f\u3059\u3063\u98db\u3070\u3057\u3066\u76f4\u63a5\u30b3\u30fc\u30c9\u304b\u3089\u5165\u3063\u305f\u306e\u306f\u826f\u304b\u3063\u305f\u3068\u601d\u3044\u307e\u3059\u3002\u30da\u30a2\u30d7\u30ed\u3068\u304b\u3001M-VM-M \u306e\u5206\u696d\u4f53\u5236\u306a\u3093\u304b\u306f\u3042\u3093\u306a\u611f\u3058\u3067\u9032\u3081\u308b\u3068\u3046\u307e\u304f\u3044\u304f\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u79c1\u306e\u767a\u8868\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306b\u3042\u308b\u306e\u3067\u3001\u3056\u3063\u3068\u89e3\u8aac\u3092\u3064\u3051\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/github.com\/moonmile\/JXUG\">http:\/\/github.com\/moonmile\/JXUG<\/a><\/p>\n<h2>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u69cb\u9020<\/h2>\n<p>\u30b3\u30fc\u30c9\u306b\u306f\u3061\u3087\u3063\u3068\u3060\u3051\u3067\u3082\u5358\u4f53\u30c6\u30b9\u30c8\u7528\u306e\u30b3\u30fc\u30c9\u3092\u4ed8\u3051\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u79c1\u304c TDD \u3092\u4f7f\u3046\u76ee\u7684\u3068\u3057\u3066\u306f\u3001\u30c6\u30b9\u30c8\u306e\u52b9\u7387\u5316\u306e\u4ed6\u306b\u3001\u300c\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\/\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4f7f\u3044\u65b9\u300d\u3092\u793a\u3059\u305f\u3081\u306b\u3082\u4f5c\u3063\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u30af\u30e9\u30b9\u3092\u3069\u306e\u3088\u3046\u306b\u4f7f\u3046\u306e\u304b\u3001\u304b\u3064\u3001\u30af\u30e9\u30b9\u3092\u4f7f\u3046\u6642\u306b\u3069\u306e\u3088\u3046\u306a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306b\u3057\u305f\u3089\u4f7f\u3044\u3065\u3089\u304f\u306f\u306a\u306a\u3089\u306a\u3044\u304b\u3001\u306e\u691c\u8a0e\u7528\u306b\u5358\u4f53\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001\u5b9f\u969b\u306b\u30af\u30e9\u30b9\u3092\u52d5\u304b\u3059\u3068\u304d\u306e\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u3001\u3044\u304d\u306a\u308a Xamarin \u306e\u30b3\u30fc\u30c9\u3067\u306f\u5927\u5909\uff08\u5b9f\u6a5f\u3067\u3057\u304b\u52d5\u4f5c\u3057\u306a\u3044\u30d1\u30bf\u30fc\u30f3\u306a\u3069\uff09\u306a\u306e\u3067\u3001\u6700\u521d\u306b WPF \u3084 Windows \u30d5\u30a9\u30fc\u30e0\u3092\u4f7f\u3063\u305f\u5c0f\u3055\u306a\u30b5\u30f3\u30d7\u30eb\u3092\u7528\u610f\u3057\u307e\u3059\u3002\u3053\u308c\u3067\u3044\u304f\u3064\u304b\u5b9f\u9a13\u3057\u305f\u5f8c\u3067\u3001\u5b9f\u969b\u306e\u30e2\u30d0\u30a4\u30eb\u30b3\u30fc\u30c9\u306b\u76f4\u3059\u3001\u3042\u308b\u3044\u306f\u7d44\u307f\u5408\u308f\u305b\u3066\u3044\u3044\u304d\u307e\u3059\u3002\u3053\u3046\u3059\u308b\u3068\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u6700\u5f8c\u306e\u307b\u3046\u306b\u306a\u3063\u3066\u5b9f\u6a5f\u30b3\u30fc\u30c9\u304c\u8907\u96d1\u306b\u306a\u3063\u3066\u3082\u3001\u5b9f\u9a13\u30a2\u30d7\u30ea\u306b\u3088\u3063\u3066\u5c11\u3057\u30c6\u30b9\u30c8\u3092\u3057\u306a\u304c\u3089\u3001\u3068\u3044\u3046\u624b\u6cd5\u304c\u53d6\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li>\/Test\/MStopWatch.Test &#8212; \u5358\u4f53\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9<\/li>\n<li>\/Test\/MStopWatch.WPF &#8212; WPF \u306b\u3088\u308b\u5b9f\u9a13\u30b3\u30fc\u30c9<\/li>\n<li>\/ViewModel\/MStopWatch.VM &#8212; WPF\/Xamarin.Forms \u306e\u5171\u901a\u306e VM<\/li>\n<li>\/ViewModel\/MStopWatchFsharp.VM &#8212; \u8a66\u3057\u306b F# \u3067\u66f8\u304d\u76f4\u3057\u305f VM<\/li>\n<li>MStopWatch &#8212; Xamarin.Froms \u306e\u5171\u901a PCL<\/li>\n<li>MStopWatch.Droid &#8212; Android \u7528<\/li>\n<li>MStopWatch.iOS &#8212; iOS \u7528<\/li>\n<li>MStopWatch.WinPhone &#8212; Windows Phone \u7528<\/li>\n<\/ul>\n<p>\u6700\u5f8c\u306e\u3001Droid\/iOS\/WinPhone \u306f Xamarin.Forms \u3092\u4f7f\u3046\u3068\u624b\u3092\u5165\u308c\u305a\u306b\u6e08\u307f\u307e\u3059\u3002\u30b7\u30df\u30e5\u30ec\u30fc\u30bf\u306e\u5834\u5408\u306f\u3001Windows Phone \u304c Hyper-V \u3092\u4f7f\u3063\u3066\u4e00\u756a\u65e9\u304f\u52d5\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001MVVM \u30d1\u30bf\u30fc\u30f3\u3092\u5f62\u4f5c\u308b\u308f\u3051\u3067\u3059\u304c\u3001\u3044\u304f\u3064\u304b\u306e\u4ed5\u639b\u3051\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002\u30b9\u30c8\u30c3\u30d7\u30a6\u30aa\u30c3\u30c1\u306e\u30bf\u30a4\u30de\u306e\u5834\u6240\u3092\u4f55\u51e6\u306b\u7f6e\u304f\u306e\u304b\u306b\u3088\u3063\u3066 VM \u306e\u66f8\u304d\u65b9\u304c\u5909\u308f\u308a\u307e\u3059\u3002\u52c9\u5f37\u4f1a\u306e\u3068\u304d\u306b\u3082\u5f37\u8abf\u3057\u307e\u3057\u305f\u304c\u3001\u7279\u306b\u6b63\u89e3\u304c\u3042\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3068\u3042\u308b\u30b3\u30fc\u30c9\u3084\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u3088\u3063\u3066\u3001\u300c\u305d\u3053\u304c\u6700\u9069\u3067\u3042\u308d\u3046\u300d\u3068\u3044\u3046\u63a8\u6e2c\u306f\u3067\u304d\u307e\u3059\u304c\u3001\u5b9f\u969b\u306b\u7f6e\u304b\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3075\u3055\u308f\u3057\u3044\u5834\u6240\u304c\u3042\u308b\u3001\u3068\u3044\u3046\u3060\u3051\u3067\u3059\u3002<\/p>\n<h2>\u30b9\u30c8\u30c3\u30d7\u30a6\u30a9\u30c3\u30c1\u30bf\u30a4\u30de\u3092 ViewModel \u306b\u7f6e\u304f<\/h2>\n<p>StopWatchVM.cs<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic class StopWatchVM : BindableBase\r\n{\r\n...\r\n    public void Start()\r\n    {\r\n        _now = DateTime.Now;\r\n        _startTime = _now;\r\n        _items.Clear();\r\n        _loop = true;\r\n        Mode = 1;\r\n        _task = new Task(async () =&gt; {\r\n            while (_loop)\r\n            {\r\n                await Task.Delay(100);\r\n                _now = DateTime.Now;\r\n                if (OnTimer != null)\r\n                    OnTimer();\r\n                else\r\n                {\r\n                    this.NowSpan = _now - _startTime;   \/\/ \u753b\u9762\u3092\u66f4\u65b0\r\n                }\r\n            }\r\n        });\r\n        _task.Start();\r\n    }\r\n<\/pre>\n<p>\u30bf\u30a4\u30de\u306f\u3001100 msec \u3067\u52d5\u304b\u3057\u3066\u3044\u307e\u3059\u3002\u975e\u5e38\u306b\u9045\u3044\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u304c\u3001\u753b\u9762\u306b\u8868\u793a\u3055\u305b\u308b\u3068\u304d\u306f 100 msec \u3067\u5341\u5206\u3067\u3001Lap \u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u3068\u304d\u306b\u306f\u6539\u3081\u3066 DateTime.Now \u304b\u3089\u53d6\u3063\u3066\u3044\u308b\u306e\u3067\u6b63\u78ba\u306a\u6642\u523b\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u3042\u305f\u308a\u304c\u3001\u8868\u793a\u7528\u306e VM \u3068\u30c7\u30fc\u30bf\u3068\u3057\u3066\u306e Model \u306e\u9055\u3044\u306b\u306a\u308a\u307e\u3059\u306d\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u30b9\u30ec\u30c3\u30c9\u8d8a\u3048\u3092\u8a31\u3059\u305f\u3081\u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570 OnTimer \u3092\u5b9a\u7fa9\u3055\u305b\u3066\u3044\u307e\u3059\u304c\u3001Android \u3067\u3082\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u306f\u5fc5\u8981\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002NowSpan \u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u66f4\u65b0\u3059\u308b\u3068\u3001INotifyPropertyChanged \u3067\u753b\u9762\u306b\u901a\u77e5\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30c8\u30c3\u30d7\u30a6\u30a9\u30c3\u30c1\u30bf\u30a4\u30de\u3092 Model \u306b\u7f6e\u304f<\/h2>\n<p>StopWatchVM2.cs<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic class StopWatchModel\r\n{\r\n...    public DateTime StartTime { get; set; }\r\n    public void Start()\r\n    {\r\n        StartTime = Now = DateTime.Now;\r\n        Items.Clear();\r\n        _loop = true;\r\n        _task = new Task(async () =&gt; {\r\n            while (_loop)\r\n            {\r\n                await Task.Delay(100);\r\n                Now = DateTime.Now;\r\n                if (OnTimer != null)\r\n                    OnTimer();\r\n            }\r\n        });\r\n        _task.Start();\r\n    }\r\n<\/pre>\n<p>Model \u306e\u307b\u3046\u306b\u30bf\u30a4\u30de\u3092\u7528\u610f\u3057\u305f\u4f8b\u3067\u3059\u3002\u3053\u306e\u610f\u56f3\u3068\u3057\u3066\u306f\u3001\u8a08\u6e2c\u6a5f\u5668\u306e\u5272\u308a\u8fbc\u307f\u30a4\u30d9\u30f3\u30c8\u3084\u3001\u5916\u90e8\u304b\u3089\u5b9a\u671f\u7684\u306b\u5272\u308a\u8fbc\u307f\u304c\u5165\u308b\u3088\u3046\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001\u30a4\u30d9\u30f3\u30c8\u304c Model -&gt; VM -&gt; View \u3078\u3068\u6570\u73e0\u3064\u306a\u304e\u306b\u306a\u308b\u306e\u3067\u3001MVVM \u306e\u307e\u307e\u4f7f\u3046\u3088\u308a\u3082 Rx \u306e\u3088\u3046\u306a\u65b9\u6cd5\u3092\u53d6\u3063\u305f\u307b\u3046\u304c\u697d\u3067\u3059\u3002<\/p>\n<h2>\u30b9\u30c8\u30c3\u30d7\u30a6\u30a9\u30c3\u30c1\u30bf\u30a4\u30de\u3092 View \u306b\u7f6e\u304f<\/h2>\n<p>\u3061\u3087\u3063\u3068\u30b5\u30f3\u30d7\u30eb\u306b\u306f\u66f8\u304d\u5fd8\u308c\u307e\u3057\u305f\u304c\u3001View \u81ea\u8eab\u306b\u30bf\u30a4\u30de\u30fc\u3092\u6301\u305f\u305b\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u30b9\u30c8\u30c3\u30d7\u30a6\u30a9\u30c3\u30c1\u306e\u5834\u5408\u306b\u306f\u3001<\/p>\n<ul>\n<li>\u5b9a\u671f\u7684\u306b\u4eba\u306e\u76ee\u306b\u89e6\u308c\u308b View \u306e\u6642\u523b\u3092\u5207\u308a\u66ff\u3048\u308b<\/li>\n<li>\u5185\u90e8\u3067\u6301\u3064\u6642\u523b\u30c7\u30fc\u30bf\u3092\u6b63\u78ba\u306b\u6301\u3064<\/li>\n<\/ul>\n<p>\u306e2\u3064\u306b\u5206\u96e2\u3067\u304d\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u3001\u5185\u90e8\u30c7\u30fc\u30bf\u306f Lap \u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067 DateTime.Now \u3092\u53d6\u5f97\u3059\u308c\u3070\u3088\u3044\u308f\u3051\u3067\u3001\u4f55\u3082\u5b9a\u671f\u7684\u306b\u5185\u90e8\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u306a\u306e\u3067\u3001\u753b\u9762\u306e\u8868\u793a\u3055\u305b\u308b View \u3060\u3051\u30bf\u30a4\u30de\u30fc\u66f4\u65b0\u3092\u4f7f\u3046\u3068\u3044\u3046\u65b9\u6cd5\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u3061\u3087\u3046\u3069\u30b2\u30fc\u30e0\u306e\u753b\u9762\u66f4\u65b0\uff08\u30b9\u30d7\u30e9\u30a4\u30c8\u6a5f\u80fd\u306a\u3069\uff09\u3092\u884c\u3046\u5834\u5408\u306b\u3001\u63cf\u753b\u306f\u30ad\u30e3\u30e9\u306e\u66f4\u65b0\u30bf\u30a4\u30df\u30f3\u30b0\u306b\u5408\u308f\u305b\u308b\u306e\u3067\u306f\u306a\u304f\u3066\u3001\u5782\u76f4\u540c\u671f\u306b\u3042\u308f\u305b\u308b\u3068\u3044\u3046\u65b9\u6cd5\u3067\u3059\u306d\u3002\u305f\u3044\u3066\u3044\u306e\u30b2\u30fc\u30e0\u306f 50fps \u7a0b\u5ea6\u3042\u308c\u3070\u5341\u5206\u306a\u306e\u3067\u300120 msec \u7a0b\u5ea6\u3067\u66f4\u65b0\u3055\u305b\u308c\u3070\u5341\u5206\u3067\u3059\u3002<br \/>\n\u306a\u306e\u3067\u3001Lap \u30bf\u30a4\u30e0\u306f msec \u5358\u4f4d\u3067\u6301\u3063\u3066\u3044\u3066\u3082\u3001\u753b\u9762\u66f4\u65b0\u306f 20 msec \u5358\u4f4d\u7a0b\u5ea6\u3067\u5341\u5206\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>View \u5358\u4f53\u306e\u66f4\u65b0\u3067\u306f\u3001WPF \u306e\u5834\u5408\u306f Storyboard \u306e\u66f4\u65b0\u30bf\u30a4\u30df\u30f3\u30b0\u3092\u4f7f\u3046\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306f\u6a5f\u4f1a\u3092\u898b\u3066\u30b5\u30f3\u30d7\u30eb\u306b\u4ed8\u3051\u52a0\u3048\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>VM \u3092 F# \u3067\u66f8\u304f<\/h2>\n<p>VM \u3084 Model \u306b\u5358\u4f53\u30c6\u30b9\u30c8\u304c\u5165\u308c\u3070\u958b\u767a\u52b9\u7387\u306f\u975e\u5e38\u306b\u4e0a\u304c\u308a\u307e\u3059\u3002\u753b\u9762\u3067\u3042\u308c\u3053\u308c\u30c6\u30b9\u30c8\u3057\u305f\u308a\u3001\u30a4\u30f3\u30bf\u30d7\u30ea\u30bf\u3067\u4e00\u6642\u7684\u306a\u30c6\u30b9\u30c8\u3092\u7e70\u308a\u8fd4\u3059\u3088\u308a\u3082\u3001\u81ea\u52d5\u30c6\u30b9\u30c8\u304c\u3067\u304d\u308b\u4f5c\u308a\u65b9\u306b\u3059\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>F# \u3067\u66f8\u3044\u305f VM \u306e\u5168\u6587\u304c\u6b21\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306f\u3001\u5358\u4f53\u30c6\u30b9\u30c8 MStopWatch.Test \u3067\u30c6\u30b9\u30c8\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\ntype StopWatchVM() = \r\n    let ev = new Event&lt;_,_&gt;()\r\n    let mutable _mode = 0\r\n    let mutable _startTime = DateTime()\r\n    let mutable _now = DateTime()\r\n    let mutable _nowSpan = TimeSpan()\r\n    let mutable _items = new ObservableCollection&lt;LapTime&gt;()\r\n    let mutable _loop = false\r\n    let mutable _task:Task = null\r\n\r\n    member this.StartButtonText \r\n        with get() = \r\n            match _mode with\r\n            | 0 -&gt; &amp;quot;Start&amp;quot;\r\n            | 1 -&gt; &amp;quot;Stop&amp;quot;\r\n            | 2 -&gt; &amp;quot;Restart&amp;quot;\r\n            | _ -&gt; &amp;quot;&amp;quot;\r\n    member this.Mode \r\n        with get() = _mode\r\n        and set(value) = \r\n            if ( _mode &lt;&gt; value ) then\r\n                _mode &lt;- value\r\n                ev.Trigger(this, PropertyChangedEventArgs(&amp;quot;StartButtonText&amp;quot;))\r\n                ev.Trigger(this, PropertyChangedEventArgs(&amp;quot;Mode&amp;quot;))\r\n    member this.Items \r\n        with get() = _items\r\n        and set(value) = \r\n            _items &lt;- value\r\n            ev.Trigger(this, PropertyChangedEventArgs(&amp;quot;Items&amp;quot;))\r\n    member this.NowSpan\r\n        with get() = _nowSpan\r\n        and set(value) = \r\n            _nowSpan &lt;- value\r\n            ev.Trigger(this, PropertyChangedEventArgs(&amp;quot;NowSpan&amp;quot;))\r\n\r\n\r\n    member this.ClickStart() =\r\n        match _mode with\r\n        | 0 -&gt; this.Start()\r\n        | 1 -&gt; this.Stop()\r\n        | 2 -&gt; this.Reset()\r\n        | _ -&gt; ()\r\n    member this.ClickLap() = this.Lap()\r\n\r\n    member this.Start() = \r\n        _now &lt;- DateTime.Now\r\n        _startTime &lt;- _now\r\n        _items.Clear()\r\n        _loop &lt;- true\r\n        this.Mode &lt;- 1\r\n        _task &lt;- new Task( fun () -&gt;\r\n                while ( _loop ) do\r\n                    ( Async.Sleep(100) |&gt; Async.StartAsTask ).Wait()\r\n                    _now &lt;- DateTime.Now\r\n                    this.NowSpan &lt;- _now - _startTime\r\n            )\r\n        _task.Start()\r\n\r\n    member this.Stop() = \r\n        _now &lt;- DateTime.Now\r\n        this.Items.Add( LapTime( this.Items.Count+1, _now, _now-_startTime))\r\n        _loop &lt;- false\r\n        this.Mode &lt;- 2\r\n\r\n    member this.Reset() = \r\n        _now &lt;- DateTime.Now\r\n        _startTime &lt;- _now\r\n        this.NowSpan &lt;- TimeSpan(0,0,0)\r\n        this.Items.Clear()\r\n        this.Mode &lt;- 0\r\n\r\n    member this.Lap() =\r\n        _now &lt;- DateTime.Now\r\n        this.Items.Add( LapTime( this.Items.Count+1, _now, _now-_startTime))\r\n\r\n    interface INotifyPropertyChanged with\r\n        &#x5B;&lt;CLIEvent&gt;]\r\n        member this.PropertyChanged = ev.Publish\r\n\r\n<\/pre>\n<h2>VM \u3092\u5358\u4f53\u30c6\u30b9\u30c8\u3059\u308b<\/h2>\n<p>Model \u3092\u81ea\u52d5\u30c6\u30b9\u30c8\u5316\u3059\u308b\u3068\u9811\u4e08\u306a\u30b3\u30fc\u30c9\u304c\u66f8\u3051\u307e\u3059\u3002\u3055\u3089\u306b\u753b\u9762\u306b\u8fd1\u3044 VM \u3092\u30c6\u30b9\u30c8\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/\/ &lt;summary&gt;\r\n\/\/\/ \u30e9\u30c3\u30d7\u3092\u5b9f\u884c\u3059\u308b\r\n\/\/\/ &lt;\/summary&gt;\r\n &#x5B;TestMethod]\r\npublic void TestOneLap()\r\n{\r\n    var vm = new StopWatchVM();\r\n    vm.Start();\r\n    Assert.AreEqual(&amp;quot;Stop&amp;quot;, vm.StartButtonText);\r\n    System.Threading.Thread.Sleep(1000);\r\n\r\n    vm.Lap();\r\n    Assert.AreEqual(&amp;quot;Stop&amp;quot;, vm.StartButtonText);\r\n    \/\/ \u3072\u3068\u3064\u3060\u3051\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\r\n    Assert.AreEqual(1, vm.Items.Count);\r\n\r\n    System.Threading.Thread.Sleep(1000);\r\n    vm.Stop();\r\n    Assert.AreEqual(&amp;quot;Restart&amp;quot;, vm.StartButtonText);\r\n}\r\n<\/pre>\n<p>VM \u306e\u69cb\u9020\u3092\u3001UI\/View \u304b\u3089\u89e6\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u3046\u307e\u304f\u5bfe\u5fdc\u3055\u305b\u3066\u3084\u308c\u3070\u3001\u3053\u306e\u3088\u3046\u306b\u30e6\u30fc\u30b6\u30fc\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u30a8\u30df\u30e5\u30ec\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002\u6700\u8fd1\u3067\u306f Test Cloud \u306e\u3088\u3046\u306b\u5b9f\u6a5f\/\u30a8\u30df\u30e5\u30ec\u30fc\u30bf\u3092\u4f7f\u3063\u3066 UI \u30d9\u30fc\u30b9\u306e\u30c6\u30b9\u30c8\u3092\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\u5168\u3066\u306e UI \u30a4\u30d9\u30f3\u30c8\u3092\u30a8\u30df\u30e5\u30ec\u30fc\u30c8\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u304a\u307e\u304b\u306a\u52d5\u4f5c\u304c\u30c6\u30b9\u30c8\u3067\u304d\u308b\u3068\u3001\u5b9f\u6a5f\u3092\u4f7f\u3063\u305f\u6253\u9375\u30c1\u30a7\u30c3\u30af\u3092\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30ab\u30b9\u30bf\u30e0\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u5229\u7528<\/h2>\n<p>MVVM \u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u3046\u3068\u3001\u4f55\u306b\u3067\u3082 Binding \u3092\u4f7f\u3063\u3066\u8868\u305d\u3046\u3068\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u5206 View \u304c\u5197\u9577\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u52c9\u5f37\u4f1a\u3067\u3082\u8a71\u3057\u307e\u3057\u305f\u304c\u3001\u672c\u6765\u306f XAML \u3092\u30c7\u30b6\u30a4\u30ca\u304c\u8a18\u8ff0\u3057\u3001\u30b3\u30fc\u30c9\u30d3\u30cf\u30a4\u30c9\u3092\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u8a18\u8ff0\u3059\u308b\u3068\u3044\u3046\u5206\u696d\u304c\u3067\u304d\u308b\u3001\u3068\u3044\u3046\u306e\u304c\u5f53\u6642\u306e\u58f2\u308a\u3067\u3057\u305f\u3002\u3067\u3059\u304c\u3001\u6700\u521d\u306e\u9803\u306b XAML \u3092\u30c7\u30b6\u30a4\u30f3\u3059\u308b\u306b\u306f\u3059\u3079\u3066\u3092\u30b3\u30fc\u30c9\u3067\u307f\u308b\u3057\u304b\u306a\u3044\u3068\u3044\u3046\u72b6\u614b\u306b\u9665\u3063\u3066\u3044\u305f\u305f\u3081\u3001XAML \u81ea\u4f53\u3082\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u66f8\u304f\u3088\u3046\u306a\u30b9\u30bf\u30a4\u30eb\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>Xamarin.Forms \u3067\u3001Button \u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u3066 Mode \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u8868\u793a\u304c\u5909\u3048\u3089\u308c\u308b\u3088\u3046\u306a\u30ab\u30b9\u30bf\u30e0\u30b3\u30fc\u30f3\u30c8\u30ed\u30fc\u30eb\u3092\u4f5c\u308a\u307e\u3059\u3002\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u81ea\u4f53\u3092\u3088\u308a\u9ad8\u6a5f\u80fd\u306a\u90e8\u54c1\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u30dc\u30bf\u30f3\u306e\u8868\u793a\u3092 Mode \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u5207\u308a\u66ff\u3048\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u304c\u3001\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u5f35\u308a\u4ed8\u3051\u305f\u308a\u3001\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u52d5\u304d\u3092\u5168\u3066 XAML \u3067\u66f8\u304f\u3088\u3046\u306a Setter \u306a\u65b9\u6cd5\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u30ab\u30b9\u30bf\u30e0\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3092\u4f5c\u3063\u3066\u3057\u307e\u3063\u305f\u307b\u3046\u304c XAML \u306e View \u304c\u8907\u96d1\u306b\u306a\u3089\u306a\u304f\u3066\u6e08\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic class CustomButton : Button\r\n{\r\n    public static BindableProperty ModeProperty =\r\n        BindableProperty.Create&lt;CustomButton, int&gt;(\r\n            p =&gt; p.Mode,\r\n            0,\r\n            defaultBindingMode: BindingMode.TwoWay,\r\n            propertyChanged: (bindable, oldValue, newValue) =&gt;\r\n            {\r\n                var uc = bindable as CustomButton;\r\n                switch (newValue)\r\n                {\r\n                    case 0: uc.Text = &amp;quot;\u958b\u59cb&amp;quot;; break;\r\n                    case 1: uc.Text = &amp;quot;\u505c\u6b62&amp;quot;; break;\r\n                    case 2: uc.Text = &amp;quot;\u30ea\u30bb\u30c3\u30c8&amp;quot;; break;\r\n                }\r\n                ((CustomButton)bindable).Mode = newValue;\r\n            });\r\n    public int Mode\r\n    {\r\n        get { return (int)GetValue(ModeProperty); }\r\n        set { SetValue(ModeProperty, value); }\r\n    }\r\n}\r\n<\/pre>\n<p>WPF \u306e\u5834\u5408\u306f\u3001DependencyProperty \u3092\u4f7f\u3046\u305f\u3081\u3001\u82e5\u5e72 Xamarin.Forms \u3068\u66f8\u304d\u65b9\u304c\u9055\u3046\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nclass CustomButton : Button \r\n{\r\n    \/\/\/ &lt;summary&gt;\r\n    \/\/\/ \u30e2\u30fc\u30c9\u3092\u6307\u5b9a\r\n    \/\/\/ &lt;\/summary&gt;\r\n    public static readonly DependencyProperty ModeProperty =\r\n        DependencyProperty.Register(\r\n            &amp;quot;Mode&amp;quot;,     \/\/ \u30d7\u30ed\u30d1\u30c6\u30a3\u540d\r\n            typeof(int),    \/\/ \u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u578b\r\n            typeof(CustomButton),\u3000 \/\/ \u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u578b\r\n            new FrameworkPropertyMetadata(   \/\/ \u30e1\u30bf\u30c7\u30fc\u30bf                   \r\n                0,\r\n                new PropertyChangedCallback((o, e) =&gt;\r\n                {\r\n                    var uc = o as CustomButton;\r\n                    if (uc != null)\r\n                    {\r\n                        int v = (int)e.NewValue;\r\n                        switch ( v )\r\n                        {\r\n                            case 0: uc.Content = &amp;quot;\u958b\u59cb&amp;quot;; break;\r\n                            case 1: uc.Content = &amp;quot;\u505c\u6b62&amp;quot;; break;\r\n                            case 2: uc.Content = &amp;quot;\u30ea\u30bb\u30c3\u30c8&amp;quot;; break;\r\n                        }\r\n                    }\r\n                })));\r\n    \/\/ \u4f9d\u5b58\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u30e9\u30c3\u30d1\u30fc\r\n    public int Mode\r\n    {\r\n        get { return (int)GetValue(ModeProperty); }\r\n        set { SetValue(ModeProperty, value); }\r\n    }\r\n}\r\n<\/pre>\n<h2>\u3072\u3068\u3064\u306e VM \u306b\u8907\u6570\u306e View \u3092\u5272\u308a\u5f53\u3066\u308b<\/h2>\n<p>\u672c\u6765\u306a\u3089\u3070\u3001View \u3068 VM \u306f\u304d\u308c\u3044\u306b\u5206\u96e2\u3059\u308b\u306f\u305a\u306a\u306e\u3067\u3001\u52d5\u7684\u306b View \u3092\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u7d4c\u7531\u3067 View\uff08XAML\uff09\u3092\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u7d50\u69cb\u96e3\u3057\u3044\u3067\u3059\u3002\u3057\u304b\u3057\u3001\u4e00\u5b9a\u306e View \u306e\u30d1\u30bf\u30fc\u30f3\u3092\u6301\u3063\u3066\u3044\u3066\u3001\u5834\u5408\u306b\u3088\u3063\u3066 XAML \u5168\u4f53\u3092\u5207\u308a\u66ff\u3048\u308b\u3068\u3044\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3053\u306e\u65b9\u6cd5\u306f\u3001\u6a29\u9650\u306e\u9055\u3046\u30e6\u30fc\u30b6\uff08\u7ba1\u7406\u30e6\u30fc\u30b6\u3001\u4e00\u822c\u30e6\u30fc\u30b6\u30fc\uff09\u3067\u306f\u753b\u9762\u3092\u30c0\u30a4\u30ca\u30df\u30c3\u30af\u306b\u5207\u308a\u66ff\u3048\u308b\u3001\u3068\u3044\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Xamarin.Forms \u306e MStopWatch \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u306f MyPage.xaml \u3068 MyPageV.xaml \u3068\u3044\u30462\u3064\u306e View \u304c\u3042\u308a\u307e\u3059\u3002VM \u304c\u540c\u3058\u3067\u3042\u3063\u3066\u3082\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3059\u308b\u3068\u304d\u306b Page \u30af\u30e9\u30b9\u3092\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3061\u306a\u307f\u306b\u3001MyPageV.xaml \u306f\u3001\u3059\u3079\u3066 View \u306e\u30b3\u30fc\u30c9\u30d3\u30cf\u30a4\u30c9\u306b\u30ed\u30b8\u30c3\u30af\u3092\u5165\u308c\u3066\u3057\u307e\u3063\u305f\u4f8b\u3067\u3059\u3002<\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u3001\u3061\u3087\u3053\u3061\u3087\u3053\u3068\u696d\u52d9\u30ce\u30a6\u30cf\u30a6\u3063\u307d\u3044\u3082\u306e\u3082\u5165\u308c\u3066\u3042\u308b Xamarin.Forms \u306e MVVM \u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u306e\u3067\u3001\u305c\u3072\u6d3b\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JXUGC #9 Xamarin.Forms Mvvm \u5b9f\u88c5\u65b9\u6cd5 Teachathon &#8211; connpass http:\/\/jxug.connpass.com\/event\/22840\/ \u306b\u3066\u3001\u7530\u6df5\u3055\u3093\u30b3\u30fc\u30c9\u306b &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/7627\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[62],"tags":[],"class_list":["post-7627","post","type-post","status-publish","format-standard","hentry","category-xamarin"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=7627"}],"version-history":[{"count":2,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7627\/revisions"}],"predecessor-version":[{"id":7629,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/7627\/revisions\/7629"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=7627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=7627"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=7627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}