標籤:style blog http color io os ar for sp
1:頁面的副檔名為:.xaml檔案類似於ASPX一樣可以編寫用戶端顯示內容和幕後處理內容
一般的前台頁面的形式為:
<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檔案
刪除Styles.xaml.cs檔案
開啟Styles.xaml檔案,寫入樣式代碼如下
<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配置關聯檔案
<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>
windows PHONE 開發-入門程式構築