【发布时间】:2017-08-28 23:49:16
【问题描述】:
我正在尝试在 Visual Studio 2015 中使用 Xamarin Forms 制作应用程序。我想将背景图像添加到屏幕/页面。到目前为止,我已经到达这里,如下面的代码所示,但它不起作用。
这是我的 MainPage.XAML 代码。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TrackMyMeds"
x:Class="TrackMyMeds.MainPage"
BackgroundImage="/Images/blue_gradient">
<StackLayout BackgroundColor="Gray" Padding="8,15,8,0">
<Label HorizontalTextAlignment="Center" Text="Welcome to TrackMyMeds" TextColor="White" FontSize="40" FontAttributes="Bold">
</Label>
<Label HorizontalTextAlignment="Center" Text="Let us take charge of your health" TextColor="Black" FontSize="18">
</Label>
<StackLayout Padding="0,40,0,15">
<Label Text="If you already have an account:" TextColor="Black">
</Label>
<Button Clicked="LoginPage_Clicked" Text="Log In Here!" BackgroundColor="#387ef5" TextColor="White" FontSize="18">
</Button>
</StackLayout>
<StackLayout Padding="0,15,0,0">
<Label Text="If you're new here then:" TextColor="Black">
</Label>
<Button Clicked="SignupPage_Clicked" Text="Sign Up Here!" BackgroundColor="#387ef5" TextColor="White" FontSize="18">
</Button>
</StackLayout>
</StackLayout>
</ContentPage>
这是我的 MainPage.xaml.cs 代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace TrackMyMeds
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void LoginPage_Clicked(object sender, EventArgs e)
{
App.Current.MainPage = new LoginPage();
}
private void SignupPage_Clicked(object sender, EventArgs e)
{
App.Current.MainPage = new SignupPage();
}
}
}
【问题讨论】:
-
图片文件在哪里?在 Forms 项目中还是在 iOS 和 Android 项目中?
标签: c# xamarin xamarin.ios xamarin.android xamarin.forms