首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LoginView in Xamarin.Form

LoginView in Xamarin.Form
EN

Stack Overflow用户
提问于 2014-11-11 22:11:36
回答 1查看 518关注 0票数 1

我正在尝试使用xamarin.form实现一个loginview。我已经在我的项目中实现了以下代码,但是,一旦我运行,它就不会在视图上显示任何内容。

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace WebComponents
{   
    public partial class LoginView : ContentPage
    {   
        public LoginView ()
        {
            InitializeComponent ();


            var profilePage = new ContentPage {
                Title = "Profile",
                Content = new StackLayout {
                    Spacing = 20,
                    Padding = 50,
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        new Entry { Placeholder = "Username" },
                        new Entry { Placeholder = "Password", IsPassword = true },
                        new Button { Text = "Login", TextColor = Color.White, BackgroundColor = Color.FromHex("77D065") }
                    }
                }
            };
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-11 22:16:21

LoginView是ContentPage的一个子类--您正在创建另一个ContentPage,profilePage,但没有使用它做任何事情。试一试:

代码语言:javascript
复制
   Entry username;
   Entry password;
   Button button;

   public LoginView ()
   {
        InitializeComponent ();

        Title = "Profile";

        Content = new StackLayout {
                Spacing = 20,
                Padding = 50,
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    (username = new Entry { Placeholder = "Username" }),
                    (password = new Entry { Placeholder = "Password", IsPassword = true }),
                    (button = new Button { Text = "Login", TextColor = Color.White, BackgroundColor = Color.FromHex("77D065") })
                }
            }
        };

        button.Clicked += Login;
    }

    public void Login(object sender, EventArgs ea) 
    {
        // check values of username and password here
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26875552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档