简介
WPF全称Windows Presentation Foundation,是.NET开发框架winform主推的GUI框架,采用xaml和C#开发。
XAML全称eXtensible Application Markup Language,是XML的变体。WPF之前的winform,mfc都采用编程语言开发静态界面,WPF首次引入描述性语言开发静态界面。
WPF可以用XAML开发界面,也可以用纯粹的C#代码开发界面
示例
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="72">
Hello, WPF!
</TextBlock>
</Grid>
</Window>
入门
主循环
显示根窗口,启动事件循环
<Application x:Class="WpfTutorialSamples.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>
using System;
using System.Collections.Generic;
using System.Windows;
namespace WpfTutorialSamples
{
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
// Create the startup window
M