locked
Incorrect/wrong namespace in XAML file of shared xamarin.forms project RRS feed

  • Question

  • User223508 posted

    I am using Visual Studio 2015 and created xamarin forms shared project/solution. I have created a custom control for progress bar in my shared project as below:

    using Xamarin.Forms;
    
    namespace XamTimer.Controls
    {
        public class CircularProgress : View
        {
        //........ my code
        }
    }
    

    and its Renderers in respective platform projects.

    But when I try to refer this control in my shared .xaml file, it gives android namespace's hard-coded reference instead of shared namespace reference:

    It sometimes takes android reference like: xmlns:controls="clr-namespace:XamFormsApp.Controls;assembly=XamFormsApp.Droid"

    AND other times it takes ios reference like: xmlns:controls="clr-namespace:XamFormsApp.Controls;assembly=XamFormsApp.iOS"

    <CarouselPage xmlns="http://xamarin.com/schemas/2014/forms" 
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:controls="clr-namespace:XamFormsApp.Controls;assembly=XamFormsApp.Droid"
                  x:Class="XamFormsApp.Views.TimerPickerView"
                  ItemsSource="{Binding Pages}">
        <controls:CircularProgress
                          WidthRequest="300"
                          HeightRequest="300"
                          Indeterminate = "{Binding IsIndeterminate}"
                          Progress = "{Binding Progress}"
                          ProgressColor="Red"
                          ProgressBackgroundColor="Gray"
                          IndeterminateSpeed = "100"/>
    </CarouselPage>
    

    Also attaching actual screenshots for better understanding.

    Please help me to set correct namespace in visual studio xaml.

    Wednesday, March 29, 2017 6:17 AM

Answers

  • User261475 posted

    Change "clr-namespace:XamFormsApp.Controls;assembly=XamFormsApp.Droid" just to "clr-namespace:XamFormsApp.Controls". If you don't set the assembly it search in the own assembly - so just what is needed for shared projects.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, March 29, 2017 7:39 AM