《Applications=Code+Markup》读书笔记 1(第一章 初识Application和Window)

知识点

[STAThread] WPF程序的Main函数必须声明为[STAThread]:

In any WPF program, the [STAThread] attribute must precede Main or the C# compiler will complain.
This attribute directs the threading model of the initial application thread to be a single-threaded apartment,
which is required for interoperability with the Component Object Model (COM).
"Single-threaded apartment" is an old COM-era, pre-.NET programming term,
but for our purposes you could imagine it to mean
our application won't be using multiple threads originating from the runtime environment.

app.Run();开始进入消息循环,可带参数(win)

介绍Application中的事件

包括Startup, SessionEnding 等 以及 可override的函数(default event handler) OnStartup , OnSessionEnding

Window 中的事件(继承自UIElement)(TextInput,MouseDown等)

Following initialization, virtually everything a program does is in response to an event.
These events usually indicate keyboard, mouse, or stylus input from the user.
The UIElement class (which refers to the user interface, of course) defines a number of keyboard-,
mouse-, and stylus-related events; the Window class inherits all those events.
One of those events is named \MouseDown. A window's \MouseDown event occurs 
whenever the user clicks the client area of the window with the mouse.

Window的一些属性(Height,Width,Top,Left; Title; WindowStartupLocation; WindowStyle; ResizeMode;WindowState )

由Background 引出Brushes(见下一章)

关键

熟悉Application和Window的事件

在需要的情况下可继承Window以及Application

在子类中override其中的一些event handler, 修改一些属性

一个WPF程序只有一个Application(对象),这个Application可创建多个Window

这些Window的各种属性都可以通过程序控制.

Window可以以Show()和ShowDialog()两种方式Show出来,弄清二者的区别

隐藏一个Window可以用Hide(),关闭则调用它的Close();

转载于:https://www.cnblogs.com/caoyang/archive/2007/09/24/904616.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值