Windows 8技巧:Windows 8中FlipView的使用技巧介绍
发布时间:2013-04-22 17:02:15 作者:佚名
我要评论
本篇文章小编为大家介绍,Windows 8技巧:Windows 8中FlipView的使用技巧。需要的朋友参考下
FlipView控件类似于翻页控件,并且是现成的翻页按钮,你只需要为其增加数据项即可。本文讲述两种方式的FlipView项目和展示。
一:直接前台FlipViewItem
复制代码
代码如下:<FlipView>
<FlipViewItem>
<Image Stretch="Uniform" Source="http://imgcache.qq.com/club/item/wallpic/items/2/3802/760_300_3802.jpg"/>
</FlipViewItem>
<FlipViewItem>
<Image Stretch="Uniform" Source="http://imgcache.qq.com/club/item/wallpic/items/3/4023/c_760_300_4023.jpg"/>
</FlipViewItem>
<FlipViewItem>
<Image Stretch="Uniform" Source="http://imgcache.qq.com/club/item/wallpic/items/3/3673/c_760_300_3673.jpg"/>
</FlipViewItem>
<FlipViewItem>
<Image Stretch="Uniform" Source="http://imgcache.qq.com/club/item/wallpic/items/7/4017/c_760_300_4017.jpg"/>
</FlipViewItem>
<FlipViewItem>
<Image Stretch="Uniform" Source="http://imgcache.qq.com/club/item/wallpic/items/2/3972/c_760_300_3972.jpg"/>
</FlipViewItem>
</FlipView>
效果如下:

二:前台设置DataTemplate,后台实体集方式添加数据项。
复制代码
代码如下:<FlipView Name="fvShow" Margin="100">
<FlipView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.Background>
<ImageBrush Stretch="Uniform" ImageSource="{Binding ImgUrl}"/>
</Grid.Background>
<TextBlock Height="30" VerticalAlignment="Top" HorizontalAlignment="Left"
Margin="180 300 0 0" FontSize="20" Foreground="Blue" Text="{Binding ImgName}"/>
<TextBlock Height="30" VerticalAlignment="Top" HorizontalAlignment="Left"
Margin="180 350 0 0" FontSize="20" Foreground="Blue" Text="{Binding ImgAddr}"/>
</Grid>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
复制代码
代码如下:/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.fvShow.ItemsSource = ImgModel.GetImgData();
}</p> <p> /// <summary>
/// 在此页将要在 Frame 中显示时进行调用。
/// </summary>
/// <param name="e">描述如何访问此页的事件数据。Parameter
/// 属性通常用于配置页。</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
}</p> <p> /// <summary>
/// 图片实体
/// </summary>
public class ImgModel
{
/// <summary>
/// 图片名字
/// </summary>
public string ImgName { get; set; }</p> <p> /// <summary>
/// 图片地址
/// </summary>
public string ImgAddr { get; set; }</p> <p> /// <summary>
/// 图片URL
/// </summary>
public string ImgUrl { get; set; }</p> <p> public static List<ImgModel> GetImgData()
{
List<ImgModel> list = new List<ImgModel>();
list.Add(new ImgModel() { ImgName = "名字:北京冬景", ImgAddr = "地址:北京市", ImgUrl = "http://imgcache.qq.com/club/item/wallpic/items/2/3922/760_300_3922.jpg" });
list.Add(new ImgModel() { ImgName = "名字:上海春景", ImgAddr = "地址:上海市", ImgUrl = "http://imgcache.qq.com/club/item/wallpic/items/7/3147/760_300_3147.jpg" });
list.Add(new ImgModel() { ImgName = "名字:天津秋景", ImgAddr = "地址:天津市", ImgUrl = "http://imgcache.qq.com/club/item/wallpic/items/6/3966/c_760_300_3966.jpg" });
list.Add(new ImgModel() { ImgName = "名字:海南夏景", ImgAddr = "地址:海南市", ImgUrl = "http://imgcache.qq.com/club/item/wallpic/items/5/3695/760_300_3695.jpg" });
list.Add(new ImgModel() { ImgName = "名字:成都风景", ImgAddr = "地址:成都市", ImgUrl = "http://imgcache.qq.com/club/item/wallpic/items/8/2518/760_300_2518.jpg" });
return list;
}
}
看此方式的效果如下:

最后如需源码请点击 Win8FlipView_jb51net 下载。
相关文章

Win8.1 KB5021294补丁月度更新汇总!(附完整更新日志)
微软已向用户发布了Win8.1月度更新汇总,补丁为KB5021294,下文为大家带来了详细的更新介绍,需要的朋友一起看看吧2022-12-15
微软警告:Win8.1系统即将停止支持,将很快弹窗提醒,建议购买 Win11/1
6月24日消息,据报道,微软正准备开展行动,通知Windows8.1用户关于该产品的停止支持日期,下面随小编一起来看看吧2022-06-24
这篇文章主要介绍了win8系统怎么加密文件?win8系统加密文件详细操作方法的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
win8系统如何设置开机密码?Win8系统设置开机密码操作教程
这篇文章主要介绍了win8系统如何设置开机密码?Win8系统设置开机密码操作教程的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
这篇文章主要介绍了Win8系统在后台运行打印机程序操作教程的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
Win8系统安全证书过期怎么办?Win8系统安全证书过期的解决方法
这篇文章主要介绍了Win8系统安全证书过期怎么办?Win8系统安全证书过期的解决方法的相关资料,需要的朋友可以参考下本文详细内容介绍2022-06-13
如何解决Win10浏览器打不开网页但能上网?最近很多用户向小编反应升级了win10系统之后在下载软件或者打开第三方网页的时候会出现病毒误报,该怎么办呢?跟随小编来看看吧2020-12-31
Win8临时文件夹如何修改路径?Win8临时文件夹文件过多会影响速度,我们可以通过修改文件路径很好的解决这一问题,下面让我们来看看如何修改2020-12-22
Win8系统如何设置鼠标左右键互换?最近很多小伙伴向小编咨询关于Win8系统设置鼠标左右键互换的问题,下面就跟随小编一起学习吧2020-12-11
Win8系统怎么关闭系统还原?最近很多win8系统的用户向小编咨询想要关闭系统还原,不知道如何操作,不妨我们一起来看看下文的教程吧2020-12-09












最新评论