一直不想写blog但是发现光看别人的有种愧疚感,现在开始把自己学习winFX的笔记写出来供大家一起学习。
winfx就是.net 3.0,包括wpf、wcf、wwf。(个人理解)
其他的不说,看个例子先:
- 建立一个wpf的工程。
- 打开window1.xaml文件,在xaml代码中写入以下代码:
<Window x:Class="FullWPFWCFWWF.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="FullWPFWCFWWF" Height="300" Width="300"
>
<Grid>
<Button Name="MyButton" HorizontalAlignment="Center" VerticalAlignment="Center"
Width="100" >确定</Button>
</Grid>
</Window>看设计器多了个按钮@_@!
我们来增加个按钮的点击事件.
<Button Name="MyButton" HorizontalAlignment="Center" VerticalAlignment="Center"
Width="100" Click="ButtonOnClick">确定</Button>
好了前台事件注册了,后台加入代码:
public partial class Window1 : System.Windows.Window
...{
public Window1()
...{
InitializeComponent();
}
void ButtonOnClick(object sender, RoutedEventArgs args)
...{
MessageBox.Show("我出现了");
}
}启动调试看下.
ok第一个小例子写成了。
HorizontalAlignment="Center" VerticalAlignment="Center" 这两句代表的是按钮的位置.我们设置成窗体的中间位置.
本文介绍了如何使用WinFX中的WPF创建简单应用程序。通过一个实例展示了如何添加按钮并为其设置点击事件,实现弹出消息框的功能。
1419

被折叠的 条评论
为什么被折叠?



