コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: Fujimoto0814/fh
        public MainViewModel()
        {
            // DialogService is used to handle dialogs
            this.DialogService = new MvvmDialogs.DialogService();
            _listData          = new ObservableCollection <SampleModel>()
            {
                new SampleModel()
                {
                    Name = "姫路しかま", Address = "兵庫県姫路市", Age = 25, Birthday = new DateTime(1974, 1, 12), Job = "プログラマー"
                },
                new SampleModel()
                {
                    Name = "元町もとこ", Address = "兵庫県神戸市中央区", Age = 45, Birthday = new DateTime(1988, 1, 12), Job = "SE"
                },
            };

            SelectionListData  = ListData.First();
            CalendarCollection = new CalendarCollectionModel(InputDatetime);

            #region non meaning
            // クラスの宣言
            var classlist = new List <SampleModel>()
            {
                new SampleModel()
                {
                    Name = "名前1", Age = 10, Address = "姫路",
                },
                new SampleModel()
                {
                    Name = "名前2", Age = 20, Address = "姫路",
                },
                new SampleModel()
                {
                    Name = "名前3", Age = 30, Address = "姫路",
                },
                new SampleModel()
                {
                    Name = "なまえ4", Age = 40, Address = "神戸",
                },
            };
            // 「名前」を含む人を取り出す
            var linq1 = classlist.Where(x => x.Name.Contains("名前"));
            // 年齢の合計
            var linq2 = classlist.Sum(x => x.Age);
            // 「名前:年齢:住所」で転写
            Func <SampleModel, string> formatMember = x => x.Name + ":" + x.Age.ToString() + ":" + x.Address;
            var linq3 = classlist.Select(formatMember);
            ListData.Aggregate(new ObservableCollection <SampleModel>(), (x, y) => x);
            #endregion
        }