Image- Xamarin.Form

时间:2014-11-11 23:05:21

标签: xamarin xamarin.forms

我已经实现了一个登录页面,现在我想添加一个标题图像;但是,图像不会显示在视图上。

    public LoginView ()
    {
        InitializeComponent ();

        Title= "Login";

        Content = new StackLayout {
            Spacing = 20,
            Padding = 50,
            VerticalOptions = LayoutOptions.Center,
            Children = {
                new Image {Source="headerImage.jpg"},
                (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;
    }

enter image description here

1 个答案:

答案 0 :(得分:2)

图像需要放在平台项目(iOS,Android等)中,而不是共享的Forms项目中。有关详细信息,请参阅Working with Images

"图像可以通过Xamarin.Forms在平台上共享,可以为每个平台专门加载,也可以下载它们进行显示。"