【WPF】

本文介绍了WPF(Windows Presentation Foundation)作为.NET框架的GUI开发组件,强调了XAML在界面设计中的作用。内容涵盖WPF的主循环、根窗口、控件的父子关系、事件绑定、属性绑定、布局系统、样式定义、控件通信、事件传递方向以及绘图功能。通过实例解析,帮助开发者掌握WPF开发的基础知识。
摘要由CSDN通过智能技术生成

简介

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值