Expression Blend 4 for Windows Phone實踐教程
之前51CTO移動開發(fā)頻道曾為您介紹過《Expression Blend 4基礎(chǔ)繪圖應用講解》,本文將為您講述如何在Expression Blend中創(chuàng)建Windows Phone 7 應用程序。
1.安裝Expression Blend 4 for Windows Phone
當安裝了Expression Blend 4英文版以及Microsoft Windows Developer Tools - ENU之后,再次運行安裝程序(下載地址http://www.microsoft.com/expression/service-packs/Blend.aspx,點擊DOWNLOAD THE WINDOWS PHONE DEVELOPER TOOLS(http://go.microsoft.com/fwlink/?LinkID=185584)。運行按照程序,選擇Installation Options:
勾選Microsoft Expression Blend 4 for Windows Phone后,點擊Next:
安裝完畢。
#p#
2.在Blend中新建WindowsPhoneHelloWorld項目
啟動Expression Blend,選擇新建項目:
輸入項目名稱WindowsPhoneHelloWorld:
點擊OK按鈕創(chuàng)建項目完畢:
在上圖中,我們可以看到整個Blend的工作區(qū)了;在Blend中我們可以更好更方便的設(shè)計應用程序界面。
選中TextBlock控件PageTitle,設(shè)置其Text屬性為Hello World!
也可直接修改XAML:
- <!--TitlePanel contains the name of the application and page title-->
- <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28" Grid.ColumnSpan="2">
- <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
- <TextBlock x:Name="PageTitle" Text="Hello World!" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
- </StackPanel>
#p#
3.運行程序
點擊F5,Blend即會把程序部署到模擬器上,并且運行模擬器:
#p#
4.調(diào)試程序
在MainPage.xaml.cs中添加一行代碼用于彈出一個對話框:
- 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;
- namespace WindowsPhoneHelloWorld
- {
- public partial class MainPage : PhoneApplicationPage
- {
- public MainPage()
- {
- InitializeComponent();
- MessageBox.Show("Test Debug in Blend", "Test", MessageBoxButton.OKCancel);
- }
- }
- }
由于Expression Blend本身是一個設(shè)計工具,并不支持調(diào)試功能,我們可以將項目在Visual Studio中運行調(diào)試。
在Projects面板中,選擇項目,單擊右鍵選擇Edit in Visual Studio:
如果遇到錯誤Cannot open in visual studio the requested operation requires elevation,請以管理員身份運行Blend:
以下為程序在Visual Studio 2010中打開的界面:
打開MainPage.xaml.cs,添加斷點,點擊調(diào)試按鈕即可開始調(diào)試:
將Express Blend這個強大的設(shè)計工具與Visual Studio結(jié)合,可以更輕松的創(chuàng)建精彩的應用程序!
原文鏈接:http://kosmisch.net/archive/2011/06/15/6c7fc4199113d162dab4bd37.aspx