安装了Microsoft .NET Framework 3.0 Redistributable Package, 这东西我可是因为这里的破网速更新了6个小时,简直郁闷~在更新的时候就听了一些新的<老罗语录>简直太爽了,在"Orcas"的Next-Gen Development Tools发布之前我还是只能通过Visual Studio来开发.NET 3.0程序,Windows Vista应该会在月底发布,不过对硬件的要求的考虑我还是暂时不会升级,使用VS2005开发的时候必须安装Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF).
今天使用WPF写了一个很简单的程序但花了不少时间,对WPF这个开发框架和模式太不熟悉了,体会最深的一点就是代码和UI真正意义上的分离,或许这真的把OO发挥到了极致,XAML记录了UI的每一部分,而且这些代码都可以转化成C#代码,但反向则不是完全兼容.
Charles Petzold写的一本关于WPF的新书Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation (Pro - Developer) (Hardcover)上市了:
http://www.amazon.com/dp/0735619573?tag=learnwpfcom-20&camp=14573&creative=327641&linkCode=as1&creativeASIN=0735619573&adid=1JSNMVK7ET6HGHN4XYXZ&
Microsoft .NET Framework 3.0 Redistributable Package下载地址:
http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=en
Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF)下载地址:
http://www.microsoft.com/downloads/details.aspx?FamilyId=F54F5537-CC86-4BF5-AE44-F5A1E805680D&displaylang=en
Microsoft Pre-release Software Visual Studio Code Name "Orcas"下载地址:
http://www.microsoft.com/downloads/details.aspx?FamilyID=82243606-d16d-445c-8949-9ee8c10cda2e&DisplayLang=en
Orcas这东西可不要乱装,听粱老大说这个是一个虚拟镜像所以要用VPC运行,我们还是期待换新电脑后装预计在2007年发布的Orcas.
下面是我今天写的类似"Hello World"的WPF代码,在这里感谢程哥和粱老大的指导:
Window1.xaml.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WPFtest
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
btn1.Click +=new RoutedEventHandler(btn1_Click);
}
public void btn1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("you waste time all the day");
lbl1.Content = "Beauty:";
// 创建一个源
BitmapImage myBitmapImage = new BitmapImage();
// BitmapImage.UriSource必须使用BeginInit/EndInit块
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"e:/beauty.jpg");
myBitmapImage.EndInit();
//把源赋给Image控件
img1.Source = myBitmapImage;
}
}
}
window1.xaml:
<Window x:Class="WPFtest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPFtest" Height="442" Width="701"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.973254086181278*" />
<ColumnDefinition Width="0.00742942050520059*" />
<ColumnDefinition Width="0.011887072808321*" />
<ColumnDefinition Width="0.00742942050520059*" />
</Grid.ColumnDefinitions>
<Button Height="23" HorizontalAlignment="Left" Margin="15,64,0,0" Name="btn1" VerticalAlignment="Top" Width="75">Hello</Button>
<Image Margin="228,26,21,77" Name="img1" />
<Label Height="21.6866666666667" HorizontalAlignment="Left" Margin="106,64.3133333333333,0,0" Name="lbl1" VerticalAlignment="Top" Width="96"></Label>
</Grid>
</Window>
代码就是以上的,下面是截图:
今天使用WPF写了一个很简单的程序但花了不少时间,对WPF这个开发框架和模式太不熟悉了,体会最深的一点就是代码和UI真正意义上的分离,或许这真的把OO发挥到了极致,XAML记录了UI的每一部分,而且这些代码都可以转化成C#代码,但反向则不是完全兼容.
Charles Petzold写的一本关于WPF的新书Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation (Pro - Developer) (Hardcover)上市了:
http://www.amazon.com/dp/0735619573?tag=learnwpfcom-20&camp=14573&creative=327641&linkCode=as1&creativeASIN=0735619573&adid=1JSNMVK7ET6HGHN4XYXZ&
Microsoft .NET Framework 3.0 Redistributable Package下载地址:
http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=en
Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF)下载地址:
http://www.microsoft.com/downloads/details.aspx?FamilyId=F54F5537-CC86-4BF5-AE44-F5A1E805680D&displaylang=en
Microsoft Pre-release Software Visual Studio Code Name "Orcas"下载地址:
http://www.microsoft.com/downloads/details.aspx?FamilyID=82243606-d16d-445c-8949-9ee8c10cda2e&DisplayLang=en
Orcas这东西可不要乱装,听粱老大说这个是一个虚拟镜像所以要用VPC运行,我们还是期待换新电脑后装预计在2007年发布的Orcas.
下面是我今天写的类似"Hello World"的WPF代码,在这里感谢程哥和粱老大的指导:
Window1.xaml.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WPFtest
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
btn1.Click +=new RoutedEventHandler(btn1_Click);
}
public void btn1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("you waste time all the day");
lbl1.Content = "Beauty:";
// 创建一个源
BitmapImage myBitmapImage = new BitmapImage();
// BitmapImage.UriSource必须使用BeginInit/EndInit块
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"e:/beauty.jpg");
myBitmapImage.EndInit();
//把源赋给Image控件
img1.Source = myBitmapImage;
}
}
}
window1.xaml:
<Window x:Class="WPFtest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPFtest" Height="442" Width="701"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.973254086181278*" />
<ColumnDefinition Width="0.00742942050520059*" />
<ColumnDefinition Width="0.011887072808321*" />
<ColumnDefinition Width="0.00742942050520059*" />
</Grid.ColumnDefinitions>
<Button Height="23" HorizontalAlignment="Left" Margin="15,64,0,0" Name="btn1" VerticalAlignment="Top" Width="75">Hello</Button>
<Image Margin="228,26,21,77" Name="img1" />
<Label Height="21.6866666666667" HorizontalAlignment="Left" Margin="106,64.3133333333333,0,0" Name="lbl1" VerticalAlignment="Top" Width="96"></Label>
</Grid>
</Window>
代码就是以上的,下面是截图: