在 Xamarin 表单中使用 syncfusion 的轮播不会出现
Carousel using syncfusion in Xamarin forms not appear
我正在尝试使用 xamarin 中的 syncfusion Carousel
表格
但是我已经根据文档编写了这段代码,但是出于某种原因
Carosel 没有出现这里是我写的代码
下面是例子:
https://help.syncfusion.com/xamarin/sfcarousel/getting-started
Xaml:
<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>
C#:
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;
}
我检查了你的代码并修改了它以通过 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;
}
我正在尝试使用 xamarin 中的 syncfusion Carousel 表格
但是我已经根据文档编写了这段代码,但是出于某种原因 Carosel 没有出现这里是我写的代码
下面是例子: https://help.syncfusion.com/xamarin/sfcarousel/getting-started
Xaml:
<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>
C#:
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;
}
我检查了你的代码并修改了它以通过 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;
}