Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How do I reference Custom Controls within a Xamarin Forms Shared Project?

$
0
0

I'm running into an issue when trying to reference my custom control within my XAML page. It seems that it needs the Assembly, but with the Shared Project template how do I do that since the assembly is based on the platform?

Case 1:

< fa:BaseContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:fa="clr-namespace:FrazzApps.Common.Pages;assembly=FrazzApps.Common"
xmlns:local="clr-namespace:MyApp.Views"
x:Class="MyApp.Pages.TimerPage">
< local:TimerView>
< /fa:BaseContentPage>

This fails with on the LoadFromXaml in the InitializeComponent method with an ArgumentNullException : {"Value cannot be null.\r\nParameter name: assemblyName"}

Case 2:

< fa:BaseContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:fa="clr-namespace:FrazzApps.Common.Pages;assembly=FrazzApps.Common"
xmlns:local="clr-namespace:MyApp.Views;assembly=MyApp"
x:Class="MyApp.Pages.TimerPage">
< local:TimerView>
< /fa:BaseContentPage>

This fails with on the LoadFromXaml in the InitializeComponent method with an FileNotFoundException : {"Could not load file or assembly 'MyApp, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"MyApp, Culture=neutral, PublicKeyToken=null"}

Case 3:

< fa:BaseContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:fa="clr-namespace:FrazzApps.Common.Pages;assembly=FrazzApps.Common"
xmlns:local="clr-namespace:MyApp.Views;assembly=MyApp.WinPhone"
x:Class="MyApp.Pages.TimerPage">
< local:TimerView>
< /fa:BaseContentPage>

This works, but is not a functional solution since it won't work on Android or iOS...

There must be something I'm missing...


Viewing all articles
Browse latest Browse all 77050

Trending Articles