Mohanad
Mohanad

Reputation: 91

CarouselView not working in Xamarin.Forms

I would like to use CarouselView , I have installed it already (CarouselView.FormsPlugin) and I checked the packeges.config of my project and it is already there :

but still I am getting this error The type or namespace name 'CarouselView' could not be found in the global namespace (are you missing an assembly reference?) how can I fix this problem?

Upvotes: 2

Views: 3234

Answers (4)

fatgL
fatgL

Reputation: 25

In my case, I had the wrong namespace in the XAML inside <ContentPage> tag. This is correct:

xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"

Upvotes: 0

Gerald Versluis
Gerald Versluis

Reputation: 33993

It looks like you're not using the official CarouselView. In the case of the CarouselView.FormsPlugin, the name is a CarouselViewControl.

Try it like this:

<controls:CarouselViewControl x:Name="myView">
    <controls:CarouselViewControl.ItemTemplate>
            <DataTemplate>
                <Label Text="{Binding .}" HorizontalOptions="Center" VerticalOptions="Center"/>

            </DataTemplate>
        </controls:CarouselViewControl.ItemTemplate>
    </controls:CarouselViewControl>

Upvotes: 4

Mohanad
Mohanad

Reputation: 91

<?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:local="clr-namespace:XamlTest"
            xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
             x:Class="XamlTest.MainPage">

    <controls:CarouselView x:Name="myView">
        <controls:CarouselView.ItemTemplate>
                <DataTemplate>
                    <Label Text="{Binding .}" HorizontalOptions="Center" VerticalOptions="Center"/>

                </DataTemplate>
            </controls:CarouselView.ItemTemplate>
        </controls:CarouselView>


</ContentPage>

Upvotes: 1

Jordy Dieltjens
Jordy Dieltjens

Reputation: 1538

Could you show your code in XAML?

Maybe you forgot to put the assembly / namespace?

If so try to put this in your content page tag: xmlns:carousel="clr-namespace:CarouselView.Forms.Plugin;assembly=CarouselView.Forms.Plugin"

When you do that you can call the control with :

Upvotes: 0

Related Questions