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

How to use the control defined in another assembly, by XAML?

$
0
0

I tried to use the custom control by XAML. For example:

<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:customs="clr-namespace:Customs;assembly=Customs"
    x:Class="FormsCustomControl.MainPage">
    <ContentPage.Content>
        <customs:CustomControl />
    </ContentPage.Content>
</ContentPage>

But the app threw a System.IO.FileNotFoundException with this messages.

image

On the other hand, the error no longer occurs when i add somewhere the c# code that refers to my Customs assembly. For example:

using Xamarin.Forms;

namespace FormsCustomControl
{   
    public partial class MainPage : ContentPage
    {   
        public MainPage ()
        {
            new Customs.CustomControl();

            InitializeComponent ();
        }
    }
}

How can I do to so that you can use a custom control using only XAML?


Viewing all articles
Browse latest Browse all 81910

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>