Xaml Xamarin表单转盘视图绑定问题

Xaml Xamarin表单转盘视图绑定问题,xaml,xamarin.forms,Xaml,Xamarin.forms,您好,我在将字符串列表绑定到旋转木马视图时遇到问题 首先,我有一个从服务器获取的对象列表 public class PostObject { public string PostOwner { get; set; } public string Id { get; set; } public string Post { get; set; } public string ProfileImage { get; set; }

您好,我在将字符串列表绑定到旋转木马视图时遇到问题 首先,我有一个从服务器获取的对象列表

public class PostObject
    {
        public string PostOwner { get; set; }
        public string Id { get; set; }
        public string Post { get; set; }
        public string ProfileImage { get; set; }
        public List<string> PostImages { get; set; }
    }
  List<PostObject> posts = new List<PostObject>();
现在到目前为止,一切正常,没有错误,但当应用程序呈现页面时,我得到了一个错误

System.TypeInitializationException:“Xamarin.Forms.ItemsView”的类型初始值设定项引发异常。


我可以追溯到旋转木马视图。当我注释掉旋转木马视图时,它工作了。所以我想我不能像我想的那样绑定或使用Carousel视图?

CarouselView过去是一个插件,现在已经成为Xamarin.Forms的一部分,在版本4中生效。您可以使用早期的XF版本,但您需要获得该版本,向XAML添加程序集引用,并将初始化代码放入特定于平台的项目中


或者,您可以升级到Xamarin.Forms 4

CarouseView以前是一个插件,现在已成为Xamarin.Forms的一部分,在版本4中生效。您可以使用早期的XF版本,但您需要获得该版本,向XAML添加程序集引用,并将初始化代码放入特定于平台的项目中


或者,您可以升级到Xamarin.Forms 4

,即使您可以在Xamarin.Forms 3.6.0.344457上看到旋转木马视图,但它仅在那里定义了一个接口。Carousel视图类中没有实现和属性


您只能在Xamarin.Forms 4.0下使用它。由于它现在仍然是一个预览版本,所以有一些限制。请参阅此处的我的帖子:了解更多信息。

尽管您可以在Xamarin.Forms 3.6.0.344457上看到Carousel视图,但它仅在其中定义了一个接口。Carousel视图类中没有实现和属性


您只能在Xamarin.Forms 4.0下使用它。由于它现在仍然是一个预览版本,所以有一些限制。有关更多信息,请参阅我的帖子。

我没有看到任何包含旋转视图的部件参考。这可能是您在火星上使用Xamarin.Forms 3.6.0.344457时出现异常@Mouse的原因吗?当我转到工具箱(Visual Studio 2017)时,我在那里看到了旋转木马视图,这就是我添加到XAML中的内容?我还需要下载控件并将其添加到我的程序集引用中吗?可能的副本我没有看到任何包含CarouselView的程序集引用。这可能是您在火星上使用Xamarin.Forms 3.6.0.344457时出现异常@Mouse的原因吗?当我转到工具箱(Visual Studio 2017)时,我在那里看到了旋转木马视图,这就是我添加到XAML中的内容?我还需要下载控件并将其添加到我的程序集引用中吗?@Mike你在Xamarin.Forms 4.0预览版上得到了预期的结果了吗?很抱歉耽搁了这么长时间,但没有。我决定在我的应用程序中使用插件CarouselView@Mike您在Xamarin.Forms 4.0预览版上获得了预期的结果吗?很抱歉,延迟太久,但没有。我决定使用我的旋转视图插件
<?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:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin"
              NavigationPage.HasNavigationBar="True"
             NavigationPage.HasBackButton="False"
             NavigationPage.BackButtonTitle="Back"
             Title="amici"
             x:Class="amici.Posts">

    <NavigationPage.TitleView>
        <StackLayout Orientation="Horizontal" VerticalOptions="Center" Spacing="10" >
            <Label x:Name="GroupTitle" TextColor="White" FontSize="Medium"/>
        </StackLayout>
    </NavigationPage.TitleView>

    <ContentPage.ToolbarItems>
        <ToolbarItem Name="iconexample" Icon="settings.png" Priority="0" Order="Primary" />
    </ContentPage.ToolbarItems>

    <ContentPage.Content>
        <StackLayout>
            <ListView x:Name="ItemsListView" 
             VerticalOptions="FillAndExpand"
             HasUnevenRows="true"
             IsPullToRefreshEnabled="true"
             IsRefreshing="{Binding IsBusy, Mode=OneWay}"
             CachingStrategy="RecycleElement">
                <!--ItemSelected="OnItemSelected"-->
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell >
                            <StackLayout Padding="10">
                                <Frame x:Name="myframe" HasShadow="True" >

                                    <Grid HorizontalOptions="FillAndExpand"  RowSpacing="0" ColumnSpacing="0"  >
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="20" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="20" />
                                            <RowDefinition Height="20" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Label Grid.Row="0"  Text="{Binding PostOwner}" LineBreakMode="WordWrap" Font="Bold,16"  />
                                        <controls:CircleImage Grid.Row="0" Margin="10" BorderColor="white" BorderThickness="1" VerticalOptions="Start" HorizontalOptions="Start" Source="{Binding ProfileImage}" Aspect="AspectFit">
                                            <controls:CircleImage.WidthRequest>
                                                <OnPlatform x:TypeArguments="x:Double">
                                                    <On Platform="Android, iOS">65</On>
                                                </OnPlatform>
                                            </controls:CircleImage.WidthRequest>
                                            <controls:CircleImage.HeightRequest>
                                                <OnPlatform x:TypeArguments="x:Double">
                                                    <On Platform="Android, iOS">65</On>
                                                </OnPlatform>
                                            </controls:CircleImage.HeightRequest>
                                        </controls:CircleImage>

                                        <Label Grid.Row="1"  Text="{Binding Post}" LineBreakMode="WordWrap" Font="Bold,16"  />

                                        <CarouselView x:Name="PostImages" Grid.Row="2" ItemsSource="{Binding PostImages}">
                                            <CarouselView.ItemTemplate>
                                                <DataTemplate>
                                                    <Image Source="{Binding .}" Aspect="AspectFill" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
                                                </DataTemplate>
                                            </CarouselView.ItemTemplate>
                                        </CarouselView>

                                        <!--<Image Grid.Row="2"  Source="{Binding ImageURL}" Aspect="AspectFill" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />-->
                                        <BoxView Grid.Row="3"  BackgroundColor="black" HeightRequest="1"  HorizontalOptions="FillAndExpand"/>
                                        <StackLayout Grid.Row="4" Orientation="Horizontal" >
                                            <Label  Text="Likes: " LineBreakMode="NoWrap" Font="Bold,14" />
                                            <Label  Text="0" LineBreakMode="NoWrap" FontSize="14" />
                                        </StackLayout>
                                        <StackLayout Grid.Row="5" Orientation="Horizontal" >
                                            <Label Text="Comments: " LineBreakMode="NoWrap"  Font="Bold,14"  HorizontalOptions="End" />
                                            <Label Text="0" HorizontalOptions="End"  LineBreakMode="NoWrap" FontSize="14" />
                                        </StackLayout>
                                        <!--<Label Grid.Row="2" Text="{Binding OwnerFullName}" LineBreakMode="NoWrap" FontSize="16" />-->
                                    </Grid>
                                </Frame>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
         </StackLayout>


    </ContentPage.Content>
</ContentPage>
public Posts (GroupInfo ginfo)
        {
            InitializeComponent ();
            GroupTitle.Text = ginfo.Title;
            CurrentGroupInfo = ginfo;
            GetDataPosts();


            ItemsListView.RefreshCommand = new Command(() => {
                GetDataPosts();
                ItemsListView.IsRefreshing = false;

            });
        }

public void GetDataPosts()
        {
            try
            {
                string apikey = Application.Current.Properties["api"].ToString();
                ItemsListView.ItemsSource = null;
                posts.Clear();

                if (RestController.GetMyPostData(ref posts, CurrentGroupInfo.Id.ToString(), apikey))
                {
                    ItemsListView.ItemsSource = posts;
                }
            }
            catch(Exception e)
            {
                Debug.WriteLine(e.Message);
            }

        }