windows PHONE 开发-入门程序构筑

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>


 

原文地址:https://www.cnblogs.com/wequst/p/4031685.html