Xamarin.Forms 4.4 version of the new features

  Microsoft recently updated the new version of xamarin.form4.4 framework that is a major advance for the current user, after the upgrade framework can support more new features for developers is a big step forward, and Microsoft He began testing new components, and other people surprise is that Microsoft has finally launched two important components CarouseView and SwipeView, but IndicatorView controls only a secondary control, and began to support the GIF format images (not supported before you dare to believe, to support the need to use other gallery).

  To use the new components, the first statement about the use of SetFlage method, add the following code APP.xaml.cs

 1 public App()
 2 {
 3     InitializeComponent();
 4  
 5     Device.SetFlags(new[] {
 6         "CarouselView_Experimental",
 7         "IndicatorView_Experimental",
 8         "SwipeView_Experimental"
 9     } );
10  
11     MainPage = new AppShell();
12 }

  A, GIF FIG movable

<Image Source="https://cataas.com/cat/gif?type=sq" IsAnimationPlaying="True"/>

Added directly in xaml Views can be in GIF Image, the default action figure is a loop if you want to stop the cycle, IsAnimationPlaying set to false.

  Two, CarouseIView and IndicatorView components.

  These two components are used in combination, you may be used alone, does not affect the function, CarouseIView component is a giant screen, the user may slide giant screen, to switch the content, vertical and horizontal sliding supports slide, and similar components CollectionView, but but slightly different, a CollectionView typically used for displaying large amounts of data, and the performance is great, is Microsoft's alternative ListView component, but mainly horizontal CarouseIView DMR function.

 1 <CarouselView x:Name="carouselView" ItemsSource="{Binding Monkeys}" >
 2                 <CarouselView.ItemTemplate>
 3                     <!-- DataTemplate that defines item appearance -->
 4                     <DataTemplate>
 5                         <StackLayout>
 6                             <Frame HasShadow="True" BorderColor="DarkGray" CornerRadius="5" Margin="20" HeightRequest="300" HorizontalOptions="Center" VerticalOptions="CenterAndExpand">
 7                                 <StackLayout>
 8                                     <Label Text="{Binding Name}" FontAttributes="Bold" FontSize="Large" HorizontalOptions="Center" VerticalOptions="Center" />
 9                                     <Image Source="{Binding ImageUrl}" Aspect="AspectFill" HeightRequest="150" WidthRequest="150" HorizontalOptions="Center" />
10                                     <Label Text="{Binding Location}" HorizontalOptions="Center" />
11                                     <Label Text="{Binding Details}" FontAttributes="Italic" HorizontalOptions="Center" MaxLines="5" LineBreakMode="TailTruncation" />
12                                 </StackLayout>
13                             </Frame>
14                         </StackLayout>
15                     </DataTemplate>
16                 </CarouselView.ItemTemplate>
17             </CarouselView>
18             <IndicatorView ItemsSourceBy="carouselView"
19                    IndicatorColor="LightGray"
20                    SelectedIndicatorColor="DarkGray"
21                    HorizontalOptions="Center" />

  Three, SwipeView components

  This is a sliding component, the support, slide down, left, and right directions, add SwipeItem to show hidden content, by SwipView.RightItems, LeftItems, TopItems, BottomItems control the direction of the slide, while SwipeStarted, SwipeChanging, SwipedEnded, CloseRequested event. Meanwhile, SwipeView defines a Close method for closing Items.

 1 <SwipeView>
 2     <SwipeView.LeftItems>
 3         <SwipeItems>
 4             <SwipeItem Text="Favorite"
 5                        IconImageSource="favorite.png"
 6                        BackgroundColor="LightGreen"
 7                        Invoked="OnFavoriteSwipeItemInvoked" />
 8             <SwipeItem Text="Delete"
 9                        IconImageSource="delete.png"
10                        BackgroundColor="LightPink"
11                        Invoked="OnDeleteSwipeItemInvoked" />
12         </SwipeItems>
13     </SwipeView.LeftItems>
14     <!-- Content -->
15 </SwipeView>

 

  

Guess you like

Origin www.cnblogs.com/zuimengaitianya/p/12152848.html