Exemple #1
0
        void Build()
        {
            var app = App.Current;
            var vm  = ViewModel = app.MainViewModel;

            NavigationPage.SetHasNavigationBar(this, false);
            BackgroundColor = Colors.BgGray3.ToColor();

            Content = new Grid {
                RowSpacing     = 0,
                RowDefinitions = Rows.Define(
                    (PageRow.Header, Auto),
                    (PageRow.Body, Star)
                    ),

                Children =
                {
                    PageHeader.Create(PageMarginSize,                            nameof(vm.Title), nameof(vm.SubTitle))
                    .Row(PageRow.Header),

                    new ScrollView {
                        Content = new StackLayout {
                            Children =
                            {
                                new Button   {
                                    Text = nameof(RegistrationCodePage)
                                }.Style(FilledButton)
                                .FillExpandH().Margin(PageMarginSize)
                                .Bind(nameof(vm.ContinueToRegistrationCommand)),

                                new Button   {
                                    Text = nameof(NestedListPage)
                                }.Style(FilledButton)
                                .FillExpandH().Margin(PageMarginSize)
                                .Bind(nameof(vm.ContinueToNestedListCommand)),

                                new Label    {
                                }.FontSize(20).FormattedText(
                                    new Span {
                                    Text = "Built with "
                                },
                                    new Span {
                                    Style = Link
                                }
                                    .BindTap(nameof(vm.ContinueToCSharpForMarkupCommand))
                                    .Bind(nameof(vm.Title)),
                                    new Span {
                                    Text = " \U0001f60e"
                                }
                                    ).CenterH()
                            }
                        }
                    }.Row(PageRow.Body)
                }
            };
        }
        void Build()
        {
            var app = App.Current;
            var vm  = ViewModel = app.MainViewModel;

            NavigationPage.SetHasNavigationBar(this, false);
            BackgroundColor = Color.AliceBlue;

            Content = new Grid
            {
                RowSpacing     = 0,
                RowDefinitions = Rows.Define((PageRow.Header, Auto), (PageRow.Body, Star)),

                Children =
                {
                    PageHeader.Create(PageMarginSize,                                             nameof(vm.Title), nameof(vm.SubTitle))
                    .Row(PageRow.Header),

                    new ScrollView
                    {
                        Content = new StackLayout
                        {
                            Children =
                            {
                                new NavigateButton("Registration code demo",                      nameof(vm.ContinueToRegistrationCommand)),
                                new NavigateButton("Nested list demo",                            nameof(vm.ContinueToNestedListCommand)),
                                new NavigateButton("Animated page demo",                          nameof(vm.ContinueToAnimatedPageCommand)),
                                new Label {
                                }
                                .FormattedText(
                                    new Span {
                                    Text = "For more information about C# Markup, see "
                                },
                                    new Span {
                                    Text = "C# Markup",                                           Style = Link
                                }
                                    .BindTapGesture(nameof(vm.ContinueToCSharpForMarkupCommand)),
                                    new Span {
                                    Text = "."
                                })
                                .CenterHorizontal()
                            }
                        }.Margin(10)
                    }.Row(PageRow.Body)
                }
            };
        }
        public MainPage()
        {
            var app = App.Current;
            var vm  = ViewModel = app.MainViewModel;

            NavigationPage.SetHasNavigationBar(this, false);

            BackgroundColor = Colors.BgGray3.ToColor();

            Content = new Grid
            {
                RowSpacing = 0,

                RowDefinitions = Rows.Define(
                    (PageRow.Header, GridLength.Auto),
                    (PageRow.Body, GridLength.Star)
                    ),

                Children =
                {
                    PageHeader.Create(
                        PageMarginSize,
                        nameof(vm.Title),                                       nameof(vm.SubTitle)
                        ).Row(PageRow.Header),

                    new ScrollView {
                        Content = new StackLayout {
                            Children =
                            {
                                new Button {
                                    Text = nameof(RegistrationCodePage),        Style                            = Styles.ButtonFilled
                                }
                                .FillExpandH().Margin(PageMarginSize).Height(44)
                                .Bind(nameof(vm.ContinueToRegistrationCommand)),

                                new Button {
                                    Text = nameof(NestedListPage),              Style                            = Styles.ButtonFilled
                                }
                                .FillExpandH().Margin(PageMarginSize).Height(44)
                                .Bind(nameof(vm.ContinueToNestedListCommand)),
                            }
                        }
                    }.Row(PageRow.Body)
                }
            };
        }
        void Build()
        {
            var app = App.Current;
            var vm  = ViewModel = app.NestedListViewModel;

            NavigationPage.SetHasNavigationBar(this, false);
            BackgroundColor = Colors.BgGray3.ToColor();

            Content = new Grid {
                RowSpacing = 0,

                RowDefinitions = Rows.Define(
                    (PageRow.Header, Auto),
                    (PageRow.Body, Star)
                    ),

                Children =
                {
                    PageHeader.Create(PageMarginSize,                                nameof(vm.Title),              nameof(vm.Subtitle),    nameof(vm.ReturnToPreviousViewCommand))
                    .Row(PageRow.Header),

                    new ListView(ListViewCachingStrategy.RecycleElement)
                    {
                        IsGroupingEnabled = true,
                        HasUnevenRows     = true,

                        BackgroundColor = Colors.BgGray3.ToColor(),
                        SeparatorColor  = Colors.BgGray3.ToColor(),

                        GroupHeaderTemplate = new DataTemplate(() => new ViewCell {
                            Height = 40,                                             View = new Grid {
                                BackgroundColor = Colors.BgGray3.ToColor(),
                                RowSpacing      = 0,
                                RowDefinitions  = Rows.Define(
                                    (GroupRow.Body,                                  Star),
                                    (GroupRow.Separator,                                               2)
                                    ),

                                Children =
                                {
                                    new StackLayout           {
                                        Orientation = StackOrientation.Horizontal,   Spacing = 5,                   Children =
                                        {
                                            new Label         {
                                            }.Font(15).Bold().TextColor(Colors.ColorValuePrimary)
                                            .Margins(left: PageMarginSize).LeftExpand().CenterV()
                                            .Bind(nameof(ListGroup.Title)),

                                            new Frame         {
                                                CornerRadius = 4,                    HasShadow = false,             BackgroundColor = Colors.Green.ToColor(),Content          =
                                                    new Label {
                                                    Text = "Odd"
                                                }.TextColor(Colors.White)
                                            }.CenterV().Margins(right: 10).Padding(9,           3)
                                            .Bind(Frame.IsVisibleProperty,           nameof(ListGroup.IsOdd)),

                                            new Button        {
                                                Text = " Add Item "
                                            }
                                            .CenterV()
                                            .Bind(nameof(ListGroup.AddItemCommand)),

                                            new Button        {
                                                Text = " Remove Group "
                                            }
                                            .CenterV().Margins(right: PageMarginSize)
                                            .Bind(Button.CommandProperty,            nameof(vm.RemoveGroupCommand), source: vm)
                                            .Bind(Button.CommandParameterProperty)
                                        }
                                    }
                                    .Row(GroupRow.Body),

                                    new BoxView               {
                                    }.Color(Colors.Gray2)
                                    .Row(GroupRow.Separator)
                                }
                            }
                        }),
        void Build()
        {
            var app             = App.Current;
            var vm              = ViewModel = app.RegistrationCodeViewModel;
            var fieldNameMargin = new Thickness(20, 10);
            var fieldMargin     = new Thickness(PageMarginSize, 0);

            NavigationPage.SetHasNavigationBar(this, false);
            BackgroundColor = Colors.BgGray3.ToColor();

            Content = new Grid {
                RowSpacing     = 0,
                RowDefinitions = Rows.Define(
                    (PageRow.Header, Auto),
                    (PageRow.Body, Star)
                    ),

                Children =
                {
                    PageHeader.Create(
                        PageMarginSize,
                        nameof(vm.RegistrationTitle),                                                             nameof(vm.RegistrationSubTitle),
                        returnToPreviousViewCommandPropertyName: nameof(vm.ReturnToPreviousViewCommand),
                        centerTitle:true
                        ).Row(PageRow.Header),

                    new ScrollView {
                        Content = new Grid {
                            RowSpacing     = 0,
                            RowDefinitions = Rows.Define(
                                (BodyRow.Prompt,                                                                                              170),
                                (BodyRow.CodeHeader,                                                                                           75),
                                (BodyRow.CodeEntry,                                                               Auto),
                                (BodyRow.Button,                                                                  Auto)
                                ),

                            ColumnDefinitions = Columns.Define(
                                (BodyCol.FieldLabel,                                                                                          160),
                                (BodyCol.FieldValidation,                                                         Star)
                                ),

                            Children =
                            {
                                new Label  {
                                    LineBreakMode = LineBreakMode.WordWrap
                                }.Font(15).Bold()
                                .Row(BodyRow.Prompt).ColSpan(All <BodyCol>()).FillExpandH().CenterV().Margin(fieldNameMargin).TextCenterH()
                                .Bind(nameof(vm.RegistrationPrompt)),

                                new Label  {
                                    Text = "Registration code"
                                }.Bold()
                                .Row(BodyRow.CodeHeader).Col(BodyCol.FieldLabel).Bottom().Margin(fieldNameMargin),

                                new Label  {
                                }.Italic()
                                .Row(BodyRow.CodeHeader).Col(BodyCol.FieldValidation).Right().Bottom().Margin(fieldNameMargin)
                                .Bind(nameof(vm.RegistrationCodeValidationMessage)),

                                new Entry  {
                                    Placeholder = "E.g. 123456",                                                  Keyboard = Keyboard.Numeric
                                }.Font(15).BackgroundColor(Colors.White).TextColor(Colors.Gray1)
                                .Row(BodyRow.CodeEntry).ColSpan(All <BodyCol>()).Margin(fieldMargin).Height(44)
                                .Bind(nameof(vm.RegistrationCode),                                                BindingMode.TwoWay),

                                new Button {
                                    Text = "Verify"
                                }.Style(FilledButton)
                                .Row(BodyRow.Button).ColSpan(All <BodyCol>()).FillExpandH().Margin(PageMarginSize)
                                .Bind(Button.IsVisibleProperty,                                                   nameof(vm.CanVerifyRegistrationCode))
                                .Bind(nameof(vm.VerifyRegistrationCodeCommand)),
                            }
                        }
                    }.Row(PageRow.Body)