示例#1
0
        public App()
        {
            _model = new PurePCLViewModel.Model();

            BindingContext = _model;
            var boundLabel = new Label
            {
                XAlign = TextAlignment.Center,
                Text   = ""
            };

            boundLabel.SetBinding(Label.TextProperty, new Binding("TheAnswer"));

            var button = new Button()
            {
                Text              = "What is the Question?",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            button.Clicked += (s, e) =>
            {
                _model.AskTheQuestion();
            };

            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        new Label {
                            XAlign = TextAlignment.Center,
                            Text   = "Welcome to ThreeLayer PCL in Forms!"
                        },
                        button,
                        boundLabel
                    }
                }
            };
        }
示例#2
0
        public App()
        {
            _model = new PurePCLViewModel.Model();

            BindingContext = _model;
            var boundLabel = new Label
            {
                XAlign = TextAlignment.Center,
                Text = ""
            };
            boundLabel.SetBinding(Label.TextProperty, new Binding("TheAnswer"));

            var button = new Button()
            {
                Text = "What is the Question?",
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            button.Clicked += (s, e) =>
            {
                _model.AskTheQuestion();
            };

            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        new Label {
                            XAlign = TextAlignment.Center,
                            Text = "Welcome to ThreeLayer PCL in Forms!"
                        },
                        button,
                        boundLabel
                    }
                }
            };
        }