代码之家  ›  专栏  ›  技术社区  ›  djklasj dsajdkla

在Xamarin表单中使用syncfusion的旋转木马未出现

  •  1
  • djklasj dsajdkla  · 技术社区  · 7 年前

    我正在尝试使用xamarin中的syncfusion旋转木马 形式

    Carosel没有出现这是我写的代码

    下面是一个例子: https://help.syncfusion.com/xamarin/sfcarousel/getting-started

      <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"></RowDefinition>
            </Grid.RowDefinitions>
    
            <syncCarousel:SfCarousel x:Name="carousel" BindingContext="{Binding CollectionOfItems}"  Offset="20" RotationAngle="45" DataSource="{Binding CollectionOfItems}"  HeightRequest="400" WidthRequest="800" />
    
            <!--<c:CarouselViewControl x:Name="CaruselViewCon" ItemsSource="{Binding MyDataSource}">
                <c:CarouselViewControl.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding LabelText}"   Aspect="Fill"  />
                    </DataTemplate>
                </c:CarouselViewControl.ItemTemplate>
            </c:CarouselViewControl>-->
        </Grid>
    

        private ObservableCollection<SfCarouselItem> collectionOfItems;
    
        public ObservableCollection<SfCarouselItem> CollectionOfItems
        {
            get
            {
                return collectionOfItems;
            }
    
            set
            {
                collectionOfItems = value;
            }
        }
    
    
        public MainPage(Conferance conferance,string userPhone, List<EventDetails> LEventDEtails,List<CPhoto> LPhoto)
        {
    
            InitializeComponent();            
            collectionOfItems.Add(new SfCarouselItem() { ImageName = LPhoto[0].Path });
            collectionOfItems.Add(new SfCarouselItem() { ImageName = LPhoto[1].Path });
            collectionOfItems.Add(new SfCarouselItem() { ImageName = LPhoto[2].Path });
    
            carousel.ItemsSource = CollectionOfItems;
            carousel.BindingContext = CollectionOfItems;
     }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Massimiliano Kraus The Angry Programmer    7 年前

    我检查了您的代码,并对其进行了修改,以通过URI显示图像:

    {
        InitializeComponent();
    
        CollectionOfItems = new ObservableCollection<SfCarouselItem>();
        collectionOfItems.Add(new SfCarouselItem() { ItemContent = new Image { Source = ImageSource.FromUri(new Uri("https://cdn.syncfusion.com/content/images/Images/Ubuntu_Server_Succinctly_img.png?v=04082017080611"))}});
        collectionOfItems.Add(new SfCarouselItem() { ItemContent = new Image { Source = ImageSource.FromUri(new Uri("https://cdn.syncfusion.com/content/images/Images/Go_Web_Development.png?v=04082017080611")) } });
        collectionOfItems.Add(new SfCarouselItem() { ItemContent = new Image { Source = ImageSource.FromUri(new Uri("https://cdn.syncfusion.com/content/images/downloads/ebooks/AutoCAD_Succinctly_coverimage.png?v=04082017080611")) } });
        collectionOfItems.Add(new SfCarouselItem() { ItemContent = new Image { Source = ImageSource.FromUri(new Uri("https://cdn.syncfusion.com/content/images/Images/MongoDB_3_Succinctly_final.png?v=04082017080611")) } });
    
        carousel.ItemsSource = CollectionOfItems;
        carousel.BindingContext = CollectionOfItems;
    }