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

shortRevoltshortRevolt USMember ✭✭
edited March 2017 in Xamarin.Forms

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.

Best Answer

  • SebastianKruseSebastianKruse US ✭✭✭
    Accepted Answer

    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.

Answers

  • SebastianKruseSebastianKruse USMember ✭✭✭
    Accepted Answer

    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.

Sign In or Register to comment.