Windows 8实用窍门系列:22.Windows 8 的SemanticZoom缩放视图

2023-12-26 07:20

本文主要是介绍Windows 8实用窍门系列:22.Windows 8 的SemanticZoom缩放视图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 在Windows 8中SemanticZoom缩放视图支持对GridView和ListView控件的视图效果进行缩放,它提供一个详细信息视图(ZoomedInView)以让用户查看详细信息,另外提供一个缩小索引视图(ZoomedOutView)让用户快速定位想要查看信息的大概范围。

  一.想要实现这种效果我们需要使用SemanticZoom控件和CollectionViewSource控件配合使用:

    SemanticZoom控件:

复制代码
    <SemanticZoom.ZoomedOutView> <!--此处填充缩小索引视图的GridView,一般情况下绑定Group.Title-->
    </SemanticZoom.ZoomedOutView><SemanticZoom.ZoomedInView> <!--此处填充平常普通的GridView,显示详细信息-->
    </SemanticZoom.ZoomedInView>
复制代码

    CollectionViewSource是一个和前台UI控件进行互动的集合源。

      Source:源数据绑定属性

      IsSourceGrouped:是否允许分组

      View:获取当前与 CollectionViewSource 的此实例关联的视图对象

       View.CollectionGroups:返回该视图关联的所有集合组。

  二.现在通过一个实例来看如何使用SemanticZoom实现缩放视图,本实例接前一篇文章实例。

    1.前台设置CollectionViewSource控件

        <Grid.Resources><CollectionViewSource x:Name="itemcollectSource" IsSourceGrouped="true" ItemsPath="ItemContent" /></Grid.Resources>

    2.前台绘制ZoomedInView视图和ZoomedOutView视图GridView

复制代码
        <SemanticZoom x:Name="semanticZoom" VerticalAlignment="Center"><SemanticZoom.ZoomedOutView><GridView ScrollViewer.IsHorizontalScrollChainingEnabled="False" ><GridView.ItemTemplate><DataTemplate> <!--注意此处绑定的是实体集的GroupTitle属性-->
                            <TextBlock Text="{Binding Group.GroupTitle}" FontSize="24"/></DataTemplate></GridView.ItemTemplate><GridView.ItemsPanel><ItemsPanelTemplate><WrapGrid ItemWidth="150" ItemHeight="75" MaximumRowsOrColumns="1" VerticalChildrenAlignment="Center" /></ItemsPanelTemplate></GridView.ItemsPanel><GridView.ItemContainerStyle><Style TargetType="GridViewItem"><Setter Property="Margin" Value="4" /><Setter Property="Padding" Value="10" /><Setter Property="BorderBrush" Value="Gray" /><Setter Property="BorderThickness" Value="1" /><Setter Property="HorizontalContentAlignment" Value="Center" /><Setter Property="VerticalContentAlignment" Value="Center" /></Style></GridView.ItemContainerStyle></GridView></SemanticZoom.ZoomedOutView><SemanticZoom.ZoomedInView>  <!--设置ScrollViewer.IsHorizontalScrollChainingEnabled="False"-->
                <GridView Name="gv_Item" ItemsSource="{Binding Source={StaticResource itemcollectSource}}" SelectedItem="{Binding ItemContent, Mode=TwoWay}" ScrollViewer.IsHorizontalScrollChainingEnabled="False"Margin="20,140,40,20"  IsSwipeEnabled="True"  ><GridView.ItemTemplate><DataTemplate><Grid Width="250" Height="200" Background="#33CCCCCC"><Grid.ColumnDefinitions><ColumnDefinition Width="110"></ColumnDefinition><ColumnDefinition></ColumnDefinition></Grid.ColumnDefinitions><Image Grid.Column="0" Margin="5,0,0,0" Source="{Binding ImageUrl}" Stretch="None"></Image><TextBlock Grid.Column="1" Margin="15,15,0,0" Foreground="Black" Text="{Binding txtTitle}"FontWeight="Bold" FontSize="16" TextWrapping="Wrap"/><TextBlock Grid.Column="1" Margin="15,40,0,0" Foreground="Black" Text="{Binding txtContent}"FontWeight="Light" FontSize="14" TextWrapping="Wrap"/></Grid></DataTemplate></GridView.ItemTemplate><GridView.ItemsPanel><ItemsPanelTemplate><VariableSizedWrapGrid Orientation="Vertical" MaximumRowsOrColumns="3" /></ItemsPanelTemplate></GridView.ItemsPanel><GridView.GroupStyle><GroupStyle><GroupStyle.HeaderTemplate><DataTemplate><Grid Margin="1,0,0,6"><Button AutomationProperties.Name="组名称" Content="{Binding GroupTitle}"/></Grid></DataTemplate></GroupStyle.HeaderTemplate><GroupStyle.Panel><ItemsPanelTemplate><VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,50,0"/></ItemsPanelTemplate></GroupStyle.Panel></GroupStyle></GridView.GroupStyle></GridView></SemanticZoom.ZoomedInView></SemanticZoom>
复制代码

    3.设置后台数据源和关联ZoomedOutView视图数据

复制代码
        public MainPage(){this.InitializeComponent();this.itemcollectSource.Source = new ViewModelData().Sourcedata;//此处需要将ZoomedOutView的视图数据结合关联ZoomedInView的集合组(semanticZoom.ZoomedOutView as ListViewBase).ItemsSource = itemcollectSource.View.CollectionGroups;}
复制代码

  三.我们看效果图如下,如需源码请点击 win8Gridview3.rar 下载。

    ZoomedOutView效果图

    ZoomedInView效果图




本文转自程兴亮博客园博客,原文链接:http://www.cnblogs.com/chengxingliang/archive/2013/05/06/2991534.html,如需转载请自行联系原作者

这篇关于Windows 8实用窍门系列:22.Windows 8 的SemanticZoom缩放视图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/538539

相关文章

Python将大量遥感数据的值缩放指定倍数的方法(推荐)

《Python将大量遥感数据的值缩放指定倍数的方法(推荐)》本文介绍基于Python中的gdal模块,批量读取大量多波段遥感影像文件,分别对各波段数据加以数值处理,并将所得处理后数据保存为新的遥感影像... 本文介绍基于python中的gdal模块,批量读取大量多波段遥感影像文件,分别对各波段数据加以数值处

基于WinForm+Halcon实现图像缩放与交互功能

《基于WinForm+Halcon实现图像缩放与交互功能》本文主要讲述在WinForm中结合Halcon实现图像缩放、平移及实时显示灰度值等交互功能,包括初始化窗口的不同方式,以及通过特定事件添加相应... 目录前言初始化窗口添加图像缩放功能添加图像平移功能添加实时显示灰度值功能示例代码总结最后前言本文将

windows系统下shutdown重启关机命令超详细教程

《windows系统下shutdown重启关机命令超详细教程》shutdown命令是一个强大的工具,允许你通过命令行快速完成关机、重启或注销操作,本文将为你详细解析shutdown命令的使用方法,并提... 目录一、shutdown 命令简介二、shutdown 命令的基本用法三、远程关机与重启四、实际应用

Debian如何查看系统版本? 7种轻松查看Debian版本信息的实用方法

《Debian如何查看系统版本?7种轻松查看Debian版本信息的实用方法》Debian是一个广泛使用的Linux发行版,用户有时需要查看其版本信息以进行系统管理、故障排除或兼容性检查,在Debia... 作为最受欢迎的 linux 发行版之一,Debian 的版本信息在日常使用和系统维护中起着至关重要的作

Windows自动化Python pyautogui RPA操作实现

《Windows自动化PythonpyautoguiRPA操作实现》本文详细介绍了使用Python的pyautogui库进行Windows自动化操作的实现方法,文中通过示例代码介绍的非常详细,对大... 目录依赖包睡眠:鼠标事件:杀死进程:获取所有窗口的名称:显示窗口:根据图片找元素:输入文字:打开应用:依

javafx 如何将项目打包为 Windows 的可执行文件exe

《javafx如何将项目打包为Windows的可执行文件exe》文章介绍了三种将JavaFX项目打包为.exe文件的方法:方法1使用jpackage(适用于JDK14及以上版本),方法2使用La... 目录方法 1:使用 jpackage(适用于 JDK 14 及更高版本)方法 2:使用 Launch4j(

windows端python版本管理工具pyenv-win安装使用

《windows端python版本管理工具pyenv-win安装使用》:本文主要介绍如何通过git方式下载和配置pyenv-win,包括下载、克隆仓库、配置环境变量等步骤,同时还详细介绍了如何使用... 目录pyenv-win 下载配置环境变量使用 pyenv-win 管理 python 版本一、安装 和

Python使用pysmb库访问Windows共享文件夹的详细教程

《Python使用pysmb库访问Windows共享文件夹的详细教程》本教程旨在帮助您使用pysmb库,通过SMB(ServerMessageBlock)协议,轻松连接到Windows共享文件夹,并列... 目录前置条件步骤一:导入必要的模块步骤二:配置连接参数步骤三:实例化SMB连接对象并尝试连接步骤四:

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

科研绘图系列:R语言扩展物种堆积图(Extended Stacked Barplot)

介绍 R语言的扩展物种堆积图是一种数据可视化工具,它不仅展示了物种的堆积结果,还整合了不同样本分组之间的差异性分析结果。这种图形表示方法能够直观地比较不同物种在各个分组中的显著性差异,为研究者提供了一种有效的数据解读方式。 加载R包 knitr::opts_chunk$set(warning = F, message = F)library(tidyverse)library(phyl