Exemple #1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            // Assignment Class Member variable
            nameLbl = new Label {
                Text = "Name"
            };
            nameEntry = new Entry();
            nameEntry.SetBinding(Entry.TextProperty, "name");

            deadlineLbl = new Label {
                Text = "Deadline"
            };
            deadlinePicker = new DatePicker();
            deadlinePicker.SetBinding(DatePicker.DateProperty, "deadline");

            // File List
            fileList = new ListView
            {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(Views.FileCell))
            };
            fileList.ItemTemplate.SetBinding(FileCell.idxProperty, "Idx");
            fileList.SetBinding(ListView.ItemsSourceProperty, "fileList");
            fileList.ItemsSource   = dao.GetFileList();
            fileList.ItemSelected += FileList_ItemSelected;
            fileUrlEntry           = new Entry {
                Placeholder = "URL", WidthRequest = 200, HeightRequest = 30
            };
            fileAddBtn = new Button {
                Text = "+", WidthRequest = 30, HeightRequest = 30, Margin = 0
            };
            fileAddBtn.Clicked += FileAddBtn_Clicked;

            fileLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    new Label {
                        Text = "File list"
                    },
                    new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Orientation     = StackOrientation.Horizontal,
                        Children        =
                        {
                            fileUrlEntry,
                            fileAddBtn
                        }
                    },
                    fileList,
                }
            };

            // Comment List
            commentList = new ListView
            {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(Views.CommentCell))
            };
            commentList.ItemTemplate.SetBinding(CommentCell.idxProperty, "Idx");
            commentList.SetBinding(ListView.ItemsSourceProperty, "commentList");
            commentList.ItemsSource   = dao.GetCommentList();
            commentList.ItemSelected += CommentList_ItemSelected;
            commentAddBtn             = new Button {
                Text = "+", WidthRequest = 30, HeightRequest = 30
            };
            commentEntry = new Entry {
                WidthRequest = 300
            };
            commentEntry.SetBinding(Entry.TextProperty, "comment");
            commentAddBtn.Clicked += CommentAddBtn_Clicked;

            commentLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    new Label {
                        Text = "Comment list"
                    },
                    new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Orientation     = StackOrientation.Horizontal,
                        Children        =
                        {
                            commentEntry,
                            commentAddBtn
                        }
                    },
                    commentList,
                }
            };

            // Buttons
            saveBtn = new Button {
                Text = "Save"
            };
            saveBtn.Clicked += SaveBtn_Clicked;

            deleteBtn = new Button {
                Text = "Delete"
            };
            deleteBtn.Clicked += DeleteBtn_Clicked;

            cancelBtn = new Button {
                Text = "Cancel"
            };
            cancelBtn.Clicked += CancelBtn_Clicked;

            layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Padding         = new Thickness(20),
                Children        =
                {
                    nameLbl,     nameEntry,
                    deadlineLbl, deadlinePicker,
                }
            };
            if (idx != -1)
            {
                layout.Children.Add(fileLayout);
                layout.Children.Add(commentLayout);
            }
            layout.Children.Add(saveBtn);
            layout.Children.Add(cancelBtn);
            if (idx != -1)
            {
                layout.Children.Add(deleteBtn);
            }

            var view = new ScrollView()
            {
                Content = layout
            };

            Content = view;
        }