WPF五分钟入门

不知道什么原因,我的专业方向总是不停变换,虽然工作很稳定。
c++ builder->asp.net->java->C# winform->vc->cad二次开发->revit二次开发
我老是不得不学习新东西,才能完成任务。

做Revit开发界面很要紧,WPF很需要。
好在我有div+css基础,并且做过一些时间Silverlight

现在才发现学过的东西早晚能用上,xml和linq在revit开发中也很常用。
啥都会啥也不精,这是本人的状态,希望大家不要像我。
今天先把WPF入个门。

打开VS2010新建一个WPF应用程序。
WPF主要为了随意控件windows控件的位置,显示比较炫的界面。

注意两点。
1.界面控制,类似div+css
通过margin,padding,background来显示复杂界面。
<Grid>类似<table>

2.事件响应、程序启动跟普通windows开发类比学习。
2.1没有main()函数,
继承自System.Windows.Application的App类相当于那个包含Main()的Program.cs
打开App.xaml在StartupUri属性里设置启动窗体
2.2事件响应和普通windows开发没什么区别。
2.3用户控件和windows用户控件也没什么区别。

代码:
MainWindow.xaml

< Window  x:Class ="WpfApp.MainWindow"
        xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
        Title
="http://dotnet.5d6d.com"  Height ="350"  Width ="525" >
    
< Grid >
        
< Grid.RowDefinitions >
            
< RowDefinition  Height ="50" ></ RowDefinition >
            
< RowDefinition  Height ="30" ></ RowDefinition >
        
</ Grid.RowDefinitions >
        
< Grid.ColumnDefinitions >
            
< ColumnDefinition  Width ="100" ></ ColumnDefinition >
            
< ColumnDefinition  Width ="150" ></ ColumnDefinition >
        
</ Grid.ColumnDefinitions >
        
< TextBox  Name ="txtValue"  Grid.Row ="0"  Grid.Column ="0"  Margin ="5,10,8,3" ></ TextBox >
        
< Button  Name ="btnOk"  Grid.Row ="1"  Grid.Column ="1"  Width ="100"  Height ="20"  Click ="btnOk_Click" > ok </ Button >
    
</ Grid >
</ Window >

App.xaml

< Application  x:Class ="WpfApp.App"
             xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri
="MainWindow.xaml" >
    
< Application.Resources >
         
    
</ Application.Resources >
</ Application >

本文源码下载:http://dotnet.5d6d.com/thread-316-1-1.html
附二级域名地址供搜索引擎收录:http://greatverve.cnblogs.com/archive/2011/06/03/wpf-5.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值