Windows Phone7自动登录功能的实现方法

程序运行后先判断是否已经保存了账号,如果没有保存账号就显示登录页面.如果有账号就自动登录跳转到主界面
。这样用户按back后就不会显示登录页面了.
打开App.xaml.cs
在public partial class App : Application中加入

bool islogin = false;

修改RootFrame_Navigating(object sender, NavigatingCancelEventArgs e); Continue reading

Posted in Window Phone 7 | Tagged , , , | 7 Comments

C# ListBox 自动滚动到底部

在ListBox中添加一条记录(ListBox.Items.Add方法)后,滚动条会自动回到顶部。我们可能更希望它自动滚动到底部,本文简要介绍几种方法。

方法一:

this.listBox1.Items.Add("new line");
this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1;
this.listBox1.SelectedIndex = -1;

在添加记录后,先选择最后一条记录,滚动条会自动到底部,再取消选择。

缺点是需两次设置选中条目,中间可能会出现反色的动画,影响美观。

方法二:

this.listBox1.Items.Add("new line");
this.listBox1.TopIndex = this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight);

通过计算ListBox显示的行数,设置TopIndex属性(ListBox中第一个可见项的索引)而达到目的。

方法二 plus:智能滚动

bool scroll = false;
if(this.listBox1.TopIndex ==
this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight))
    scroll = true;
this.listBox1.Items.Add("new line");
if (scroll)
    this.listBox1.TopIndex = this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight);

在添加新记录前,先计算滚动条是否在底部,从而决定添加后是否自动滚动。

既可以在需要时实现自动滚动,又不会在频繁添加记录时干扰用户对滚动条的控制。

文章来源:http://blog.nxun.com/archives/28

Posted in Window Phone 7 | Tagged | 5 Comments

Phone7程序无法调试错误The application could not be launched for debugging

当调试程序时,出现错误“The application could not be launched for debugging”,
解决方法:搞半天发现不小心把SplashScreenImage.jpg文件的Build Action改成了Compile,改回Content重新Build一下就OK了。
是到这个地方找到的方案
http://www.touchfirst.com/Blog/65-solved-windows-phone-7-error-application-could-not-be-launched-for-debugging.aspx
SOLVED: Windows Phone 7 Error “Application could not be launched for debugging”
9/25/2010 3:26:25 PM
While debugging my WP7 application, I got the following error: “Application could not be launched for debugging.

Solved it by following these steps:

1.I verified that my WP7 application wasn't installed on the target device and that there wasn't any splash screen in the project.
2.Then, uninstall the application and in Visual Studio perform the following steps:
•Add an image file with the name SplashScreenImage.jpg to the project.
•In Solution Explorer, right-click the file and select Properties.
•In the Properties pane, set Build Action to Content.
•Rebuild the application and redeploy it.
Posted in Window Phone 7 | Tagged | 1 Comment

为Windows Phone7开发的油耗计算器

主要是为了学习开发。
需要用到的知识点:独立存储,
需要用到Toolkit,请到http://silverlight.codeplex.com/releases/view/55034下载
xml文件代码:
=====================================================

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 System.Windows.Interop;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;

Continue reading

Posted in Window Phone 7 | Tagged | 4 Comments

WindwsPhone7开发学习笔记(二)

1,使用Expressin Blend创建动画:
新建项目,设计组件,在Objects and Timeline中新建StoryBoard1, 在时间线上设计动画。让动画运行的代码this.Storyboard1.Begin();循环播放代码this.Storyboard1.RepeatBehavior = RepeatBehavior.Forever;
2, 使用XElement
使用XElement要using system.xml.linq,要using system.xml.linq,需要在referances中添加system.xml.linq;

Posted in Window Phone 7, 其他... | Tagged , , | 7 Comments