CodexBloom - Programming Q&A Platform

Visual Studio 2022 - scenarios When Attempting to Use Custom XAML Control in Xamarin.Forms Project

πŸ‘€ Views: 87 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-12
xamarin visual-studio xaml C#

I'm working through a tutorial and I've searched everywhere and can't find a clear answer. I'm working with a frustrating scenario while trying to integrate a custom XAML control in my Xamarin.Forms project using Visual Studio 2022. After defining my custom control in a separate assembly, I added a reference to it and included the appropriate namespace in my XAML file. However, when I try to build the project, I run into the following behavior message: ``` Xamarin.Forms.Xaml.XamlParseException: Position 10:10. Type 'MyNamespace.MyCustomControl' not found in xmlns"clr-namespace:MyNamespace;assembly=MyCustomAssembly" ``` I've confirmed that the control is properly defined in the library and that it has the necessary public access modifiers. Here’s the relevant part of my XAML: ```xml <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyNamespace;assembly=MyCustomAssembly" x:Class="MyApp.Views.MyPage"> <local:MyCustomControl x:Name="myCustomControl" /> </ContentPage> ``` I have also cleaned and rebuilt the solution, and I even deleted the `bin` and `obj` folders manually, but the scenario continues. The control works perfectly when tested in a separate project. Could this be a question with the way Visual Studio is handling the assembly references, or is there something else I might have overlooked? If anyone has faced a similar scenario or has insights on how to resolve this, I would greatly appreciate your help! For context: I'm using C# on Ubuntu. I'd really appreciate any guidance on this.