我正在使用便攜式Xamarin表單項目。當我調試我得到這個錯誤我的網頁類型的對象與目標類型不匹配'Xamarin.Forms.ContentView'
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"
x:Class="Project1.Views.WebView1">
<ContentView.Content>
</ContentView.Content>
</ContentPage>
xaml.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace Proje1.Views
{
public partial class WebView1 : ContentPage
{
public WebView1()
{
InitializeComponent();
Label header = new Label
{
Text = "WebView",
FontSize = 20,
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center
};
WebView wView = new WebView
{
Source = new UrlWebViewSource
{
Url = "https://www.acikakademi.com",
},
VerticalOptions = LayoutOptions.FillAndExpand
};
this.Content = new StackLayout
{
Children =
{
header,
wView
}
};
}
}
}
我應該怎麼做才能解決這個問題?
但是,當我使它從ContentView繼承,我得到錯誤App.cs.我應該如何設置App.cs中的初始頁面? –
你會得到什麼錯誤?你怎麼試圖顯示你的網頁? –
你好,我問過這裏http://stackoverflow.com/questions/39724234/cannot-implicily-convert-type-to-xamarin-forms-page –