Visual Studio是一款完備的工具和服務,可幫助您爲Microsoft平臺和其餘平臺建立各類各樣的應用程序。在本系列教程中將介紹如何爲圖像編輯建立基本的用戶界面,有任何建議或提示請在下方評論區留言,咱們會及時處理。express
在第 1 部分中介紹了使用 XAML 設計器和 Visual Studio 提供的其餘工具,本文將繼續介紹使用 XAML 編輯器直接處理 XAML 標記。編輯器
首先將根佈局 Grid 替換爲 RelativePanel。 利用 RelativePanel,可更加輕鬆地相對於面板或其餘部分 UI 從新排列 UI 塊,而後添加 GridView 控件以顯示你的數據。工具
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock x:Name="TitleTextBlock" Text="Collection" Margin="24,0,0,24" Style="{StaticResource TitleTextBlockStyle}"/> </Grid>以後
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock x:Name="TitleTextBlock" Text="Collection" Margin="24,0,0,24" Style="{StaticResource TitleTextBlockStyle}"/> </RelativePanel>
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock x:Name="TitleTextBlock" Text="Collection" Margin="24,0,0,24" Style="{StaticResource TitleTextBlockStyle}"/> </RelativePanel>添加到如下 TextBlock 以後
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock x:Name="TitleTextBlock" Text="Collection" Margin="24,0,0,24" Style="{StaticResource TitleTextBlockStyle}"/> <!-- Add the GridView here. --> </RelativePanel>
ImageGridView.ItemsSource = Images;這會將 GridView 的 ItemsSource 屬性設置爲應用的 Images 集合,併爲 GridView 提供要顯示的內容。
這是運行應用並確保一切正常工做的好地方。 它應該以下所示。佈局
這部分將建立 DataTemplate,以告訴 GridView 如何顯示你的數據,目前將僅添加佔位符以幫助建立所需的佈局。 在 XAML 數據綁定教程中,你將用 ImageFileInfo 類中的實際數據替換這些佔位符。spa
將數據模板添加到網格視圖設計
xmlns:telerikInput="using:Telerik.UI.Xaml.Controls.Input"添加到如下最後一個xmlns條目後面
<Page x:Name="page" x:Class="PhotoLab.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:PhotoLab" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:telerikInput="using:Telerik.UI.Xaml.Controls.Input" mc:Ignorable="d" NavigationCacheMode="Enabled">
<Page.Resources> <DataTemplate x:Key="ImageGridView_DefaultItemTemplate"> <Grid/> </DataTemplate> </Page.Resources>
<GridView x:Name="ImageGridView" Margin="0,0,0,8" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True" RelativePanel.Below="TitleTextBlock" ItemTemplate="{StaticResource ImageGridView_DefaultItemTemplate}"/>
<Grid/>以後
<Grid Height="300" Width="300" Margin="8"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> </Grid>
<Grid Height="300" Width="300" Margin="8"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Image x:Name="ItemImage" Source="Assets/StoreLogo.png" Stretch="Uniform" /> <StackPanel Orientation="Vertical" Grid.Row="1"> <TextBlock Text="ImageTitle" HorizontalAlignment="Center" Style="{StaticResource SubtitleTextBlockStyle}" /> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <TextBlock Text="ImageFileType" HorizontalAlignment="Center" Style="{StaticResource CaptionTextBlockStyle}" /> <TextBlock Text="ImageDimensions" HorizontalAlignment="Center" Style="{StaticResource CaptionTextBlockStyle}" Margin="8,0,0,0" /> </StackPanel> <telerikInput:RadRating Value="3" IsReadOnly="True"> <telerikInput:RadRating.FilledIconContentTemplate> <DataTemplate> <SymbolIcon Symbol="SolidStar" Foreground="White" /> </DataTemplate> </telerikInput:RadRating.FilledIconContentTemplate> <telerikInput:RadRating.EmptyIconContentTemplate> <DataTemplate> <SymbolIcon Symbol="OutlineStar" Foreground="White" /> </DataTemplate> </telerikInput:RadRating.EmptyIconContentTemplate> </telerikInput:RadRating> </StackPanel> </Grid>
如今,運行應用以查看 GridView 以及你剛剛建立的項模板。 可是可能不會看到分級控件,由於它的白星在白色背景中。orm