[源码下载]

背水一战 Windows 10 (48) - 控件(集合类): FlipView

作者:webabcd

介绍
背水一战 Windows 10 之 控件(集合类)

  • FlipView

示例
FlipView 的示例
Controls/CollectionControl/FlipViewDemo.xaml

<Page
x:Class="Windows10.Controls.CollectionControl.FlipViewDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.CollectionControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <!--定义 ListBox(用于显示小点点)的样式-->
<Page.Resources>
<Style x:Key="ItemContainerStyle" TargetType="ListBoxItem">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="20"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates" >
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver"/>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates" >
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
<Storyboard>
<ColorAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="0" To="#FF58CC0C" />
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedUnfocused">
<Storyboard>
<ColorAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="0" To="#FF58CC0C" />
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedPressed">
<Storyboard>
<ColorAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="0" To="#FF58CC0C" />
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedPointerOver">
<Storyboard>
<ColorAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="0" To="#FF58CC0C" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="fillColor" IsHitTestVisible="False" Width="32" Height="20" Fill="#FFBFBFBF" Margin="5,0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ListBoxStyle" TargetType="ListBox">
<Setter Property="Foreground" Value="{StaticResource ListBoxForegroundThemeBrush}"/>
<Setter Property="Background" Value="{StaticResource ListBoxBackgroundThemeBrush}"/>
<Setter Property="BorderBrush" Value="{StaticResource ListBoxBorderThemeBrush}"/>
<Setter Property="BorderThickness" Value="{StaticResource ListBoxBorderThemeThickness}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled"/>
<Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="True"/>
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled"/>
<Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="True"/>
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="TabNavigation" Value="Once"/>
<Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}"/>
<Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused"/>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ScrollViewer x:Name="ScrollViewer" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" Padding="{TemplateBinding Padding}" TabNavigation="{TemplateBinding TabNavigation}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10" Orientation="Horizontal"> <!--
FlipView - 翻转视图控件
UseTouchAnimationsForAllNavigation - 是否提供一致的动画体验(无论是触控模式,还是按钮模式,还是编程模式)。如果只对触控模式使用过渡动画,才需要设置为 false
--> <!--
在 XAML 中通过 FlipViewItem 指定 FilpView 的每一项
-->
<FlipView Width="320" Height="240" Margin="5 5 0 0" HorizontalAlignment="Left" VerticalAlignment="Top"
UseTouchAnimationsForAllNavigation="True">
<FlipView.Items>
<FlipViewItem>
<TextBlock Text="我是 TextBlock" />
</FlipViewItem>
<FlipViewItem>
<Image Source="/Assets/StoreLogo.png" Stretch="Fill" />
</FlipViewItem>
</FlipView.Items>
</FlipView> <!--
FlipView 和 ListBox(用于显示小点点)联动
-->
<Grid Margin="20 5 0 0">
<FlipView Name="flipView" Width="320" Height="240" HorizontalAlignment="Left" VerticalAlignment="Top"
UseTouchAnimationsForAllNavigation="True"
ItemsSource="{x:Bind Data.Items}">
<FlipView.ItemTemplate>
<DataTemplate x:DataType="local:FlipViewDataSource">
<Grid>
<Image Width="320" Height="240" Source="{Binding Image}" Stretch="Fill"/>
<TextBlock Text="{x:Bind Title, Mode=OneWay}" FontSize="24" Foreground="White" Padding="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>
</DataTemplate>
</FlipView.ItemTemplate>
<FlipView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</FlipView.ItemsPanel>
</FlipView> <ListBox Name="listBox" Width="320" Height="40" HorizontalAlignment="Left" VerticalAlignment="Top" Background="#A5000000" Margin="0 200 0 0 "
ItemContainerStyle="{StaticResource ItemContainerStyle}"
Style="{StaticResource ListBoxStyle}"
SelectedItem="{Binding SelectedItem, ElementName=flipView, Mode=TwoWay}"
ItemsSource="{x:Bind flipView.ItemsSource}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid> </StackPanel>
</Grid>
</Page>

Controls/CollectionControl/FlipViewDemo.xaml.cs

/*
* FlipView - 翻转视图控件(继承自 Selector, 请参见 /Controls/SelectionControl/SelectorDemo.xaml)
*/ using System;
using System.Collections.ObjectModel;
using Windows.UI.Xaml.Controls;
using Windows10.Common; namespace Windows10.Controls.CollectionControl
{
public sealed partial class FlipViewDemo : Page
{
public FlipViewDemo()
{
this.InitializeComponent();
} // FlipView 和 ListBox 的数据源
public FlipViewDataSource Data { get; set; } = new FlipViewDataSource();
} // 用于提供数据
public sealed class FlipViewDataSource : BindableBase
{
private static Uri _baseUri = new Uri("ms-appx:///"); public FlipViewDataSource(String title, String picture)
{
this._title = title;
this._picture = picture;
} private string _title = string.Empty;
public string Title
{
get { return this._title; }
set { this.SetProperty(ref this._title, value); }
} private Uri _image = null;
private String _picture = null;
public Uri Image
{
get
{
return new Uri(_baseUri, this._picture);
} set
{
this._picture = null;
this.SetProperty(ref this._image, value);
}
} private ObservableCollection<object> _items = new ObservableCollection<object>();
public ObservableCollection<object> Items
{
get { return this._items; }
} public FlipViewDataSource()
{
Items.Add(new FlipViewDataSource("aaa", "Assets/StoreLogo.png"));
Items.Add(new FlipViewDataSource("bbb", "Assets/StoreLogo.png"));
Items.Add(new FlipViewDataSource("ccc", "Assets/StoreLogo.png"));
Items.Add(new FlipViewDataSource("ddd", "Assets/StoreLogo.png"));
Items.Add(new FlipViewDataSource("eee", "Assets/StoreLogo.png"));
}
}
}

OK
[源码下载]

背水一战 Windows 10 (48) - 控件(集合类): FlipView的更多相关文章

  1. 背水一战 Windows 10 (55) - 控件(集合类): SemanticZoom, ISemanticZoomInformation

    [源码下载] 背水一战 Windows 10 (55) - 控件(集合类): SemanticZoom, ISemanticZoomInformation 作者:webabcd 介绍背水一战 Wind ...

  2. 背水一战 Windows 10 (49) - 控件(集合类): Pivot, Hub

    [源码下载] 背水一战 Windows 10 (49) - 控件(集合类): Pivot, Hub 作者:webabcd 介绍背水一战 Windows 10 之 控件(集合类) Pivot Hub 示 ...

  3. 背水一战 Windows 10 (50) - 控件(集合类): ItemsControl - 基础知识, 数据绑定, ItemsPresenter, GridViewItemPresenter, ListViewItemPresenter

    [源码下载] 背水一战 Windows 10 (50) - 控件(集合类): ItemsControl - 基础知识, 数据绑定, ItemsPresenter, GridViewItemPresen ...

  4. 背水一战 Windows 10 (51) - 控件(集合类): ItemsControl - 项模板选择器, 数据分组

    [源码下载] 背水一战 Windows 10 (51) - 控件(集合类): ItemsControl - 项模板选择器, 数据分组 作者:webabcd 介绍背水一战 Windows 10 之 控件 ...

  5. 背水一战 Windows 10 (52) - 控件(集合类): ItemsControl - 自定义 ItemsControl, 自定义 ContentPresenter

    [源码下载] 背水一战 Windows 10 (52) - 控件(集合类): ItemsControl - 自定义 ItemsControl, 自定义 ContentPresenter 作者:weba ...

  6. 背水一战 Windows 10 (53) - 控件(集合类): ItemsControl 的布局控件 - ItemsStackPanel, ItemsWrapGrid

    [源码下载] 背水一战 Windows 10 (53) - 控件(集合类): ItemsControl 的布局控件 - ItemsStackPanel, ItemsWrapGrid 作者:webabc ...

  7. 背水一战 Windows 10 (54) - 控件(集合类): ItemsControl 的布局控件 - OrientedVirtualizingPanel, VirtualizingStackPanel, WrapGrid

    [源码下载] 背水一战 Windows 10 (54) - 控件(集合类): ItemsControl 的布局控件 - OrientedVirtualizingPanel, VirtualizingS ...

  8. 背水一战 Windows 10 (56) - 控件(集合类): ListViewBase - 基础知识, 拖动项

    [源码下载] 背水一战 Windows 10 (56) - 控件(集合类): ListViewBase - 基础知识, 拖动项 作者:webabcd 介绍背水一战 Windows 10 之 控件(集合 ...

  9. 背水一战 Windows 10 (57) - 控件(集合类): ListViewBase - 增量加载, 分步绘制

    [源码下载] 背水一战 Windows 10 (57) - 控件(集合类): ListViewBase - 增量加载, 分步绘制 作者:webabcd 介绍背水一战 Windows 10 之 控件(集 ...

随机推荐

  1. ajax post 请求 ,java端使用 request.getParameter 获取不到数据问题

    js端 $.ajax({ type:'POST', data:{a:1}, url:_this.apiUrl+url, dataType:'json',//使用jsonp方式请求 contentTyp ...

  2. redis集群中的主从复制架构(3主3从)

    架构图如下 首先开启6个实例,这里为了演示方便,只是在一个linux上开启了6个redis实例 6380 (主)   6480 (从) 6381(主)   6481(从) 6382(主)   6482 ...

  3. python包与模块导入

    一 .module 通常模块为一个文件,直接使用import来导入就好了.可以作为module的文件类型有".py".".pyo".".pyc&quo ...

  4. KiB和KB的区别

    原文链接:http://blog.csdn.net/starshine/article/details/8226320 原来没太注意MB与MiB的区别,甚至没太关注还有MiB这等单位,今天认真了一下, ...

  5. mybatis拦截器案例之获取结果集总条数

    最近做的项目前端是外包出去的,所以在做查询分页的时候比较麻烦 我们需要先吧结果集的条数返回给前端,然后由前端根据页面情况(当前页码,每页显示条数)将所需参数传到后端. 由于在项目搭建的时候,是没有考虑 ...

  6. springboot深入学习(五)-----spring data、事务

    spring data项目是spring解决数据访问问题的一系列解决方案,包含了大量关系型数据库以及非关系型数据库的访问解决方案. 一.spring data jpa 1.简介 jpa是一套规范,不提 ...

  7. (19)3 moons and a planet that could have alien life

    https://www.ted.com/talks/james_green_3_moons_and_a_planet_that_could_have_alien_life/transcript00:1 ...

  8. orika实现对象复制

    1.新建maven工程orika-demo,引入orika依赖,其中pom.xml如下 <?xml version="1.0" encoding="UTF-8&qu ...

  9. matlab2016b和c# .net4.0混合编程

    参考:https://www.cnblogs.com/eniac12/p/4390845.html 主要想用c#写软件界面,利用matlab绘图,或者用里面的遗传算法. 我的环境是:Win10 64位 ...

  10. zk可视化工具

    也是无意中接触到zk,搞得有点头大,之前都是通过crt连通服务后,在服务上通过命令去查看节点下的数据的,十分的不方便,后来发现了可视化工具这玩意儿还真的是好用,看节啊点下的数据啥的一目了然,我用过的有 ...