我用CarouselView制作了一个照片滑块,有时照片会出现,而其他时候则不会出现,并且会出现白色的背景,它会像这样来回移动。
Xaml代码:
<?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:Test01"
xmlns:forms="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
x:Class="Test01.MainPage">
<StackLayout >
<Label Text="Images " FontSize="30" Margin="20"/>
<forms:CarouselView x:Name="MainCarouselView">
<forms:CarouselView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding .}" x:Name="image" Aspect="AspectFill"/>
</DataTemplate>
</forms:CarouselView.ItemTemplate>
</forms:CarouselView>
</StackLayout>
</ContentPage>代码背后:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using System.Xml;
namespace Test01
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
var image = new List<ImageSource>
{
ImageSource.FromResource("Test01.Images.Photo01.jpeg"),
ImageSource.FromResource("Test01.Images.Photo02.jpg"),
ImageSource.FromResource("Test01.Images.Photo03.jpg"),
ImageSource.FromResource("Test01.Images.Photo04.jpg"),
};
MainCarouselView.ItemsSource = image;
}
}}
问题不在于照片,因为我转换了它们,继续尝试用一张照片,它可以工作,然后加上其他的照片,我就得到了这个问题。
发布于 2020-05-04 14:06:56
可能是图像预加载问题,特别是如果图像很大且需要很长时间才能下载。考虑懒洋洋地装..。- boateng 9月26日‘18日下午5:30
https://stackoverflow.com/questions/52522840
复制相似问题