我使用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