Reputation: 1217
I am using Xamarin forms with FreshMvvm framework. I am creating pages in Xaml. I want to use content view to resume in multiple pages.
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();
}
}
}
When I am trying to use contentsView in a page homepage, I am getting an error : Could not load file or assembly coc.core or one of its assembly.
Can anyone advice, if anything is wrong in my code.
Thanks.
Upvotes: 0
Views: 882
Reputation: 16230
It probably means your assembly name is wrong. Instead of trying to correct it, you can just ignore it, as it seems that you're referencing the current assembly.
So your HomePage.xaml
could look like:
<?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"
Title ="Home">
Upvotes: 1
Reputation: 493
Please change into as following :
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Coc.Core;assembly=Coc.Core"
x:Class="Coc.Core.StartUpPage"
Title ="Home">
Upvotes: 1