Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows 8 + VS 開發教學:SemanticZoom 縮放檢視實作

編輯:Win8 系統應用技巧

Windows 8 的 SemanticZoom 控制項支援對 GridView 與 ListView 進行語意縮放,提供兩種檢視模式:

  • ZoomedInView(詳細檢視):顯示完整資料內容。
  • ZoomedOutView(縮放索引檢視):顯示群組標題或摘要,供快速跳轉定位。

核心控制項與屬性

SemanticZoom 控制項結構

<SemanticZoom>
  <SemanticZoom.ZoomedOutView>
    <!-- 此處放置縮放索引檢視的 GridView,通常綁定 Group.Title -->
  </SemanticZoom.ZoomedOutView>
  <SemanticZoom.ZoomedInView>
    <!-- 此處放置一般詳細資料的 GridView -->
  </SemanticZoom.ZoomedInView>
</SemanticZoom>

CollectionViewSource 關鍵屬性

  • Source:資料來源綁定屬性。
  • IsSourceGrouped:是否啟用群組。
  • View:取得目前關聯的檢視物件。
  • View.CollectionGroups:傳回該檢視關聯的所有群組集合。

實作範例(接續前文範例)

1. 前台宣告 CollectionViewSource

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

2. 定義 ZoomedInView 與 ZoomedOutView 的 GridView

完整 XAML 程式碼請參考原文,重點包括:

  • ZoomedOutView:使用 WrapGrid 版面配置,ItemTemplate 綁定 Group.GroupTitle 顯示群組標題。
  • ZoomedInView:設定 ItemsSource="{Binding Source={StaticResource itemcollectSource}}",使用 VariableSizedWrapGrid 版面,定義 GroupStyle 顯示群組標題按鈕。

透過 SemanticZoom 與 CollectionViewSource 搭配,即可輕鬆實作具備語意縮放功能的資料瀏覽介面,提升觸控裝置上大量資料的導覽效率。

Copyright © Windows教程網 All Rights Reserved