1:頁面的擴展名爲:.xaml文件相似於ASPX同樣能夠編寫客戶端顯示內容和後臺處理內容express
通常的前臺頁面的形式爲:工具
<Page x:Class="MyFirstApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyFirstApp" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
<!-- 引用命名空間--> xmlns:TabCtl="using:CustomControl"
<!-- 調用後臺pageSizeChanged方法--> SizeChanged="pageSizeChanged"
<!-- 設置頁面背景顏色爲白色--> Background="White"> <!-- 上面工具欄--> <Page.TopAppBar> <AppBar x:Name="topBar" IsSticky="True" Style="{StaticResource TopBar}" Closed="ModeToolBar_Closed" Opened="topBar_Opened" > <Grid x:Name="MenuGrid" VerticalAlignment="Center"> <Grid.ColumnDefinitions> <ColumnDefinition Width="71"/> <ColumnDefinition MinWidth="615" Width="*" /> <ColumnDefinition Width="105> </Grid.ColumnDefinitions> <AppBarButton x:Name="tooltest1" Label="test1" Click="btntest_Click"></AppBarButton> <AppBarButton x:Name="tooltest2" Grid.Column="2" Label="test2" IsEnabled="False"></AppBarButton> </Grid> </AppBar> </Page.TopAppBar> <!-- 下面工具欄--> <Page.BottomAppBar> <AppBar x:Name="ModeToolBar" IsSticky="True" Style="{StaticResource BottomAppBar}" > <Grid x:Name="EditGrid" VerticalAlignment="Center"> <Grid.ColumnDefinitions> <ColumnDefinition Width="53" /> <ColumnDefinition Width="105" /> </Grid.ColumnDefinitions> <AppBarButton x:Name="tooltest3" Grid.Column="1" HorizontalAlignment="Center" Label="test3" ></AppBarButton> <AppBarButton x:Name="tooltest4" Grid.Column="2" HorizontalAlignment="Center" Label="test4" ></AppBarButton> </Grid> </AppBar> </Page.BottomAppBar> </Page>
2:利用StaticResource引用樣式的通常步驟
建立Styles文件夾,並在文件夾中建立Styles.xaml文件spa
刪除Styles.xaml.cs文件code
打開Styles.xaml文件,寫入樣式代碼以下orm
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyFirstAppStyles">
<Style x:Key="TopBar" TargetType="AppBar"> <Setter Property="Height" Value="85"/> <Setter Property="Background" Value="#CC222846"/> </Style>
</ResourceDictionary>
在App.xaml配置關聯文件xml
<Application x:Class="MyFirstApp.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyFirstApp"> <!--關聯Resources文件--> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Styles/Styles.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application>