登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Code@Pig Home

喜欢背着一袋Code傻笑的Pig .. 忧美.欢笑.记忆.忘却 .之. 角落

 
 
 

日志

 
 

[WPF] Hello, WPF~  

2011-03-04 21:21:38|  分类: gui_WPF |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
从 Win32 API 到 MFC,从 Windows Form 到 WPF(Windows Presentation Foundation),M$上写UI的东东还真是变化多多。
WPF通过xaml来描述布局,通过C#来写事件逻辑,嗯,符合目前UI设计的范式。而且号称“一键发布",可以发布到win32 or web平台,这个看起来不错,哈。

额,我尝试了一下 web 发布,kao,居然是给ie弄了个插件。鬼才用它 - -!

我们来写个小程序看看。
--------------------- HelloWorld.xaml ------------------------
<Window
  x:Class="kcode.wpf.HelloWorld"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Hello, WPF">

  <Button
    x:Name="button"
    Width="200"
    Height="25"
    Click="button_Click">Click me</Button>

</Window>
--------------------- HelloWorld.xaml.cs ------------------------
using System;
using System.Windows;
using System.Windows.Controls;

namespace kcode.wpf {
public partial class HelloWorld : Window {
public HelloWorld() {
InitializeComponent();
}
void button_Click(object sender, RoutedEventArgs e) {
MessageBox.Show("Hello");
}
}
}
--------------------------- MyApp.xaml -----------------------------
<Application
  x:Class="kcode.wpf.MyApp"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Startup="AppStartup">
</Application>
--------------------------- MyApp.xaml.cs -----------------------------
using System;
using System.Windows;

namespace kcode.wpf {
public partial class MyApp : Application {
void AppStartup(object sender, StartupEventArgs e) {
Window window = new HelloWorld();
window.Show();
}
}
}
---------------------------- Project.csproj -------------------------------
<Project
  DefaultTargets="Build"
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <OutputType>winexe</OutputType>
    <OutputPath>.\</OutputPath>
    <AssemblyName>HelloWorld</AssemblyName>
  </PropertyGroup>

  <ItemGroup>
    <ApplicationDefinition Include="MyApp.xaml" />
    <Page Include="HelloWorld.xaml" />
    <Compile Include="HelloWorld.xaml.cs">
      <DependentUpon>HelloWorld.xaml</DependentUpon>
    </Compile>
    <Compile Include="MyApp.xaml.cs">
      <DependentUpon>MyApp.xaml</DependentUpon>
    </Compile>
    <Reference Include="System" />
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
  </ItemGroup>

  <Import Project="$(MsbuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MsbuildBinPath)\Microsoft.WinFX.targets" />
</Project>
-------------------------------------------------------------------------------
> msbuild
 ...
> HelloWorld.exe
-------------------------------------------------------------------------------

[WPF] Hello, WPF~ - kasicass - Code@Pig Home
 
哇,看起来还是挺繁琐的。。
  评论这张
 
阅读(927)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018