Windows Phone 自定义一个启动画面
1.新建一个UserControl
<UserControl x:Class="LoadingPage.PopupSplash"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="" d:DesignWidth=""> <Grid x:Name="LayoutRoot" Background="White" Width="" Height="">
<ProgressBar HorizontalAlignment="Left" Margin="0,755,0,0" Name="progressBar1" Width="" Background="DarkRed" />
<TextBlock HorizontalAlignment="Left" Margin="171,656,0,97" Name="textBlock1" Text="Loading..." Width="" Foreground="Black" FontSize="" />
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes; namespace LoadingPage
{
public partial class PopupSplash : UserControl
{
public PopupSplash()
{
InitializeComponent();
this.progressBar1.IsIndeterminate = true;//指示进度条是使用重复模式报告一般进度
}
}
}
MainPage.xaml没有变动
<phone:PhoneApplicationPage
x:Class="LoadingPage.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="" d:DesignHeight=""
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True"> <!--LayoutRoot 是包含所有页面内容的根网格-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions> <!--TitlePanel 包含应用程序的名称和页标题-->
<StackPanel x:Name="TitlePanel" Grid.Row="" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="页面名称" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel> <!--ContentPanel - 在此处放置其他内容-->
<Grid x:Name="ContentPanel" Grid.Row="" Margin="12,0,12,0"></Grid>
</Grid>
</phone:PhoneApplicationPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Controls.Primitives;
using System.ComponentModel;
using System.Threading; namespace LoadingPage
{
public partial class MainPage : PhoneApplicationPage
{
private Popup popup;
private BackgroundWorker backroungWorker;
// 构造函数
public MainPage()
{
InitializeComponent();
ShowPopup();
} private void ShowPopup()
{
this.popup = new Popup();
this.popup.Child = new PopupSplash();//设置 Popup 控件的内容,把自定义的PopupSplash控件填充到popup控件上
this.popup.IsOpen = true;
StartLoadingData();//开始加载数据
} private void StartLoadingData()
{
//使用BackgroundWorker在单独的线程上执行操作
backroungWorker = new BackgroundWorker();
//调用 RunWorkerAsync后台操作时引发此事件,即后台要处理的事情写在这个事件里面
backroungWorker.DoWork += new DoWorkEventHandler(backroungWorker_DoWork);
//当后台操作完成事件
backroungWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backroungWorker_RunWorkerCompleted);
//开始执行后台操作
backroungWorker.RunWorkerAsync();
} //后台操作完成 void backroungWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Dispatcher.BeginInvoke(() =>
{
this.popup.IsOpen = false;//关闭popup 注意要使用Dispatcher.BeginInvoke开跟UI通讯
} );
} //后台操作处理
void backroungWorker_DoWork(object sender, DoWorkEventArgs e)
{
// 程序初始化处理 这里只是模拟了一下
Thread.Sleep();
}
}
}
Windows Phone 自定义一个启动画面的更多相关文章
- Android 启动画面
如果你的程序初始化时间过长,那么在初始化之前,程序会现实一个空白的activity页,十分难看. 添加一个启动画面的方法就是为响应的activity加入自定义的Theme,并在theme中设定 and ...
- c#制作简单启动画面的方法
本文实例讲述了c#制作简单启动画面的方法.分享给大家供大家参考.具体分析如下: 启动画面是程序启动加载组件时一个让用户稍微耐心等待的提示框.一个好的软件在有启动等待需求时必定做一个启动画面.启动画面可 ...
- Pyqt QSplashScreen启动画面
多大数应用程序启动时都会在程序完全启动时显示一个启动画面,在程序完全启动后消失.程序启动画面可以显示一些有关产品的信息,让用户在等待程序启动的同时了解有关产品的功能,也是一个宣传的方式.QSplash ...
- VC++编程中为程序加入启动画面功能
如何为自己的程序加入启动画面 观察我们平常使用的软件,当我们双击软件的时候,会在主界面出现前,先行出现一个启动画面,由于前一阵子写了一个基于对话框的程序,亲自实验了下,今天就为大家简单的介绍下,在我 ...
- Android应用启动画面
原文地址: [Android]应用启动画面 - 空客的日志 - 网易博客 http://blog.163.com/da7_1@126/blog/static/104072678201291921028 ...
- QSplashScreen类实现Qt程序启动画面
QSplashScreen类实现Qt程序启动画面 收藏人:zwsj 2013-09-13 | 阅:569 转:6 | 来源 | 分享 程序启动 ...
- 【Android】应用启动画面
几乎所有的Android应用程序都会有一个启动画面,展示自己的LOGO,本版信息,或者更人性化一点的,在很长的加载信息中,变换一些显示的文字等,让无聊的等待时间添加点调味剂. 具体实现来说,应该创建一 ...
- C# WinForm程序添加启动画面
如果程序在装载时需要进行较长时间的处理,最好使用启动画面,一方面美化程序,一方面可以不使用户面对着一片空白的程序界面. 我手头上一个小项目主界面启动时需要检查用户文件及运行环境是否有效,需要一段时间处 ...
- 在iOS App 中添加启动画面
你可以认为你需要为启动画面编写代码,然而Apple 让你可以非常简单地在Xcode中完成.不需要编写代码,你仅需要在Xcode中进行一些配置. 1.什么是启动画面(Splash Screen)? 启动 ...
随机推荐
- kettle优化
http://blog.csdn.net/cissyring/archive/2008/05/29/2494130.aspx 1. Join 我得到A 数据流(不管是基于文件或数据库),A包含fiel ...
- 关于Unity中的帧动画组件的编写
一.帧动画 1: 美术准备好一个连续动作的离散图片;2: 程序在准确的时间来切换这个图片;3: 优点: 简单,速度快; 缺点:资源占用相对过大; 二.frame_anim组件编写 1: 代码里面强制要 ...
- 关于Cocos2d-x中图集中图片的调用
1.首先在Resources文件夹下要有打包好的图集文件和相同名称的plist文件. shoot.png shoot.plist shoot_background.png shoot_backgrou ...
- Intellij IDEA Module 的Language Level的问题
最近从github上fork了张开涛的Shiro代码,IDE是Intellij IDEA.发现无论是Project还是Module,默认的Language Level都是JDK 1.5,而且每次修改都 ...
- pclzip 压缩文件与解压
类PclZip.class.php下载:PclZip.rar<?php header("Content-type: text/html; charset=utf-8"); f ...
- App 应用通过网页打开 App Store
NSURL *url = nil; if ([[[UIDevice currentDevice] systemVersion] intValue] >= 7.0) { //iOS7 使用旧的网址 ...
- MVC+LINQToSQL的Repository模式之(二)数据基类
namespace Data.TEST{ /// <summary> /// 数据操作基类 /// </summary> public abstract ...
- 谈谈django里的Contex和RequestContext---向模板里添加全局变量
一直很想仔细研究一下,我在django模板里,可以直接访问变量user, request之类的变量,哪里来的,到底都有哪些?这会儿周五,我有空来仔细看看代码. 模拟一下需求: 我们做一个在线商城,需要 ...
- DEDECMS教程:首页实现分页的两种方法
有两种办法可以实现: 一.用arclist标签+Ajax实现织梦首页分页 二.交叉栏目ID 实现织梦首页分页 一.用arclist标签+Ajax实现织梦首页分页 1.必须在首页<head> ...
- mysql数据库中,查看数据库的字符集(所有库的字符集或者某个特定库的字符集)
需求描述: mysql中,想要查看某个数据库的字符集.通过information_schma模式下的schemata表来查询 环境描述: mysql版本:5.7.21-log 操作过程: 1.查看in ...