簡體   English   中英

Xamarin.Forms 輪播視圖

[英]Xamarin.Forms Carousel View

我正在使用 CarouselView 制作照片滑塊,有時照片會出現,有時不會出現並出現白色背景,並且像這樣繼續前進和后退

Xml代碼:

<?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; 
       }
   }

}

問題不在於照片,因為我切換了它們並不斷嘗試使用 1 張照片,然后將其添加到其他照片中,我就遇到了這個問題

可能是圖像預加載問題,特別是如果圖像很大並且需要很長時間才能下載.. 考慮延遲加載它們.. –boateng 2018 年 9 月 26 日 17:30

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM