我使用FreshMvvm框架的Xamarin格式。我正在Xaml中創建頁面。我想要使用內容視圖在多個頁面中恢復。Xamarin格式:使用內容視圖問題
ContentView.xaml:
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Coc.Core.ContentsView">
<ContentView.Content>
<StackLayout BackgroundColor="Silver">
<SearchBar Placeholder="Search" BackgroundColor="Olive" />
</StackLayout>
</ContentView.Content>
</ContentView>
ContentView.xaml,CS:
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Coc.Core
{
public partial class ContentsView : ContentView
{
public ContentsView()
{
InitializeComponent();
}
}
}
Homepage.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="Coc.Core.StartUpPage"
xmlns:local="clr-namespace:Coc.Core;assembly=Coc.Core"
Title ="Home">
<ContentPage.Content>
<StackLayout BackgroundColor="Silver" Spacing="30" Padding ="20,50,20,10" >
<Image />
<SearchBar Placeholder="Search" />
<Label Text="Hello" TextColor="Red" Style="{StaticResource infoLabelStyle}"/>
<local:ContentsView />
</StackLayout>
</ContentPage.Content>
</ContentPage>
個Homepage.xaml.cs:
using System;
using System.Collections.Generic;
using FreshMvvm;c
using Xamarin.Forms;
namespace Coc.Core
{
public partial class StartUpPage : ContentPage
{
public StartUpPage()
{
InitializeComponent();
}
}
}
當我試圖在一個頁面的主頁使用contentsView,我得到一個錯誤:無法加載文件或程序coc.core或其組件的一個。
任何人都可以建議,如果在我的代碼中有任何錯誤。
謝謝。
是 「Coc.Core」 在您的視圖所在的PCL組件的實際名稱? – Jason
是的。它是命名空間 – TheDeveloper
不,不是命名空間。您的項目創建的DLL的實際名稱。在Build - > Output – Jason